@m-kopa/launchpad-cli 0.76.0 → 0.77.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/CHANGELOG.md +20 -0
- package/dist/bundle/upload.d.ts +16 -0
- package/dist/bundle/upload.d.ts.map +1 -1
- package/dist/cli.js +2071 -442
- package/dist/commands/admin-cli-sessions.d.ts +6 -0
- package/dist/commands/admin-cli-sessions.d.ts.map +1 -0
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/agreement.d.ts +44 -0
- package/dist/commands/agreement.d.ts.map +1 -0
- package/dist/commands/app-lints.d.ts +14 -0
- package/dist/commands/app-lints.d.ts.map +1 -0
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/disable.d.ts +42 -0
- package/dist/commands/disable.d.ts.map +1 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/login.d.ts +4 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/dispatcher.d.ts.map +1 -1
- package/dist/http/api-client.d.ts +16 -2
- package/dist/http/api-client.d.ts.map +1 -1
- package/dist/http/error-envelope.d.ts +13 -1
- package/dist/http/error-envelope.d.ts.map +1 -1
- package/dist/http/errors.d.ts +18 -0
- package/dist/http/errors.d.ts.map +1 -1
- package/dist/scaffold/secure-api-template.d.ts +57 -0
- package/dist/scaffold/secure-api-template.d.ts.map +1 -0
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/skills/launchpad-content-pr/SKILL.md +48 -7
- package/skills/launchpad-deploy/SKILL.md +208 -8
- package/skills/launchpad-deploy-status/SKILL.md +88 -3
- package/skills/launchpad-destroy/SKILL.md +29 -3
- package/skills/launchpad-identity/SKILL.md +31 -1
- package/skills/launchpad-ingest/SKILL.md +11 -6
- package/skills/launchpad-integration-contract/SKILL.md +1 -1
- package/skills/launchpad-onboard/SKILL.md +21 -1
- package/skills/launchpad-report/SKILL.md +1 -1
- package/skills/launchpad-status/SKILL.md +8 -1
package/dist/cli.js
CHANGED
|
@@ -19,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
19
19
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
20
20
|
|
|
21
21
|
// src/version.ts
|
|
22
|
-
var CLI_VERSION = "0.
|
|
22
|
+
var CLI_VERSION = "0.77.0";
|
|
23
23
|
|
|
24
24
|
// src/config.ts
|
|
25
25
|
import { readFileSync } from "node:fs";
|
|
@@ -116,9 +116,15 @@ function decodeErrorText(text, context) {
|
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
var REVOCATION_UNAVAILABLE_CODE = "revocation_unavailable";
|
|
120
|
+
var DEFAULT_REVOCATION_RETRY_AFTER_SEC = 30;
|
|
121
|
+
function revocationUnavailableMessage(retryAfterSec = DEFAULT_REVOCATION_RETRY_AFTER_SEC) {
|
|
122
|
+
return "the Launchpad session check is temporarily unavailable, so the request was not run. " + `Retry in about ${retryAfterSec} s. ` + "Do not run `launchpad login` again: logging in again does not help, " + "this is a platform fault, not a problem with your session.";
|
|
123
|
+
}
|
|
124
|
+
function formatErrorEnvelope(envelope, options = {}) {
|
|
125
|
+
const message = envelope.code === REVOCATION_UNAVAILABLE_CODE ? revocationUnavailableMessage(options.retryAfterSec) : envelope.message;
|
|
120
126
|
const lines = [
|
|
121
|
-
`bot returned HTTP ${envelope.status} for ${envelope.endpoint} ` + `[${envelope.code}]: ${
|
|
127
|
+
`bot returned HTTP ${envelope.status} for ${envelope.endpoint} ` + `[${envelope.code}]: ${message}`
|
|
122
128
|
];
|
|
123
129
|
if (envelope.source !== undefined || envelope.sourceSha !== undefined) {
|
|
124
130
|
lines.push(`source: ${envelope.source ?? "unspecified"}` + (envelope.sourceSha === undefined ? "" : ` @ ${envelope.sourceSha ?? "none"}`));
|
|
@@ -230,6 +236,18 @@ class UnauthenticatedError extends Error {
|
|
|
230
236
|
class ForbiddenError extends Error {
|
|
231
237
|
code = "forbidden";
|
|
232
238
|
}
|
|
239
|
+
var EXIT_AGREEMENT_REQUIRED = 43;
|
|
240
|
+
|
|
241
|
+
class AgreementRequiredError extends ForbiddenError {
|
|
242
|
+
reason;
|
|
243
|
+
version;
|
|
244
|
+
constructor(message, reason, version) {
|
|
245
|
+
super(message);
|
|
246
|
+
this.name = "AgreementRequiredError";
|
|
247
|
+
this.reason = reason;
|
|
248
|
+
this.version = version;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
233
251
|
|
|
234
252
|
class NotFoundError extends Error {
|
|
235
253
|
serverCode;
|
|
@@ -291,6 +309,16 @@ class ApiError extends Error {
|
|
|
291
309
|
}
|
|
292
310
|
}
|
|
293
311
|
|
|
312
|
+
class RevocationUnavailableError extends ApiError {
|
|
313
|
+
retryAfterSec;
|
|
314
|
+
constructor(envelope, retryAfterSec) {
|
|
315
|
+
super(envelope);
|
|
316
|
+
this.name = "RevocationUnavailableError";
|
|
317
|
+
this.retryAfterSec = retryAfterSec;
|
|
318
|
+
this.message = formatErrorEnvelope(envelope, { retryAfterSec });
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
294
322
|
class TransportError extends Error {
|
|
295
323
|
code = "transport_error";
|
|
296
324
|
}
|
|
@@ -1098,6 +1126,14 @@ function buildAuthorizationUrl(params) {
|
|
|
1098
1126
|
|
|
1099
1127
|
// src/http/api-client.ts
|
|
1100
1128
|
var MAX_ERROR_BODY_BYTES = 256 * 1024;
|
|
1129
|
+
var MAX_REVOCATION_RETRY_AFTER_SEC = 30;
|
|
1130
|
+
var revocationRetryHooks = {
|
|
1131
|
+
sleep: (ms) => new Promise((resolve2) => setTimeout(resolve2, ms)),
|
|
1132
|
+
notice: (line) => {
|
|
1133
|
+
process.stderr.write(`${line}
|
|
1134
|
+
`);
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1101
1137
|
async function apiJson(cfg, opts, fetcher = fetch) {
|
|
1102
1138
|
const res = await apiRaw(cfg, opts, fetcher);
|
|
1103
1139
|
let parsed;
|
|
@@ -1141,11 +1177,29 @@ async function apiRaw(cfg, opts, fetcher = fetch) {
|
|
|
1141
1177
|
};
|
|
1142
1178
|
if (body !== undefined)
|
|
1143
1179
|
init.body = body;
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1180
|
+
if (opts.signal !== undefined)
|
|
1181
|
+
init.signal = opts.signal;
|
|
1182
|
+
const send = async () => {
|
|
1183
|
+
try {
|
|
1184
|
+
return await fetcher(url, init);
|
|
1185
|
+
} catch (e) {
|
|
1186
|
+
throw recordedFault(new TransportError(`network error calling ${url}: ${describe7(e)}`));
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
let res = await send();
|
|
1190
|
+
if (res.status === 503 && await isRevocationUnavailable(res)) {
|
|
1191
|
+
const retryAfterSec = readRetryAfterSec(res);
|
|
1192
|
+
if (retryAfterSec <= MAX_REVOCATION_RETRY_AFTER_SEC) {
|
|
1193
|
+
await res.body?.cancel().catch(() => {
|
|
1194
|
+
return;
|
|
1195
|
+
});
|
|
1196
|
+
revocationRetryHooks.notice(`launchpad: the session check is temporarily unavailable; retrying once in ${retryAfterSec} s. ` + "Do not run `launchpad login` again.");
|
|
1197
|
+
await revocationRetryHooks.sleep(retryAfterSec * 1000);
|
|
1198
|
+
res = await send();
|
|
1199
|
+
}
|
|
1200
|
+
if (res.status === 503 && await isRevocationUnavailable(res)) {
|
|
1201
|
+
throw recordedFault(new RevocationUnavailableError(await readErrorEnvelope(res, opts.path), readRetryAfterSec(res)));
|
|
1202
|
+
}
|
|
1149
1203
|
}
|
|
1150
1204
|
if (res.status === 426) {
|
|
1151
1205
|
throw recordedFault(await decodeUpgradeRequired(res, opts.path));
|
|
@@ -1156,6 +1210,9 @@ async function apiRaw(cfg, opts, fetcher = fetch) {
|
|
|
1156
1210
|
}
|
|
1157
1211
|
if (res.status === 403) {
|
|
1158
1212
|
const envelope = await readErrorEnvelope(res, opts.path);
|
|
1213
|
+
if (envelope.code === "agreement_required") {
|
|
1214
|
+
throw recordedFault(new AgreementRequiredError(`${envelope.serverMessage ?? "You need to accept the Launchpad access agreement."}` + "\nRun `launchpad agreement show` to read it, then `launchpad agreement accept`.", envelope.reason ?? "none", null));
|
|
1215
|
+
}
|
|
1159
1216
|
const hint = forbiddenHint(envelope, opts.path);
|
|
1160
1217
|
throw recordedFault(new ForbiddenError(`bot returned 403 for ${opts.path}: ${formatErrorEnvelope(envelope)}` + (hint === null ? "" : `
|
|
1161
1218
|
${hint}`)));
|
|
@@ -1174,6 +1231,21 @@ ${hint}`)));
|
|
|
1174
1231
|
clearFault();
|
|
1175
1232
|
return res;
|
|
1176
1233
|
}
|
|
1234
|
+
async function isRevocationUnavailable(res) {
|
|
1235
|
+
const body = await readErrorText(res.clone());
|
|
1236
|
+
if (body.kind !== "text")
|
|
1237
|
+
return false;
|
|
1238
|
+
const envelope = decodeErrorText(body.text, {
|
|
1239
|
+
status: res.status,
|
|
1240
|
+
endpoint: ""
|
|
1241
|
+
});
|
|
1242
|
+
return envelope.code === REVOCATION_UNAVAILABLE_CODE;
|
|
1243
|
+
}
|
|
1244
|
+
function readRetryAfterSec(res) {
|
|
1245
|
+
const raw = res.headers.get("retry-after");
|
|
1246
|
+
const n = raw === null ? NaN : Number.parseInt(raw, 10);
|
|
1247
|
+
return Number.isFinite(n) && n > 0 ? n : DEFAULT_REVOCATION_RETRY_AFTER_SEC;
|
|
1248
|
+
}
|
|
1177
1249
|
async function decodeUpgradeRequired(response, endpoint) {
|
|
1178
1250
|
const body = await readErrorText(response);
|
|
1179
1251
|
if (body.kind === "text") {
|
|
@@ -2225,7 +2297,23 @@ function deployBundleError(envelope, body) {
|
|
|
2225
2297
|
...typeof body.head_sha === "string" ? { head_sha: body.head_sha } : {},
|
|
2226
2298
|
...paths === undefined ? {} : { paths },
|
|
2227
2299
|
...typeof body.reason === "string" ? { reason: body.reason } : {},
|
|
2228
|
-
...readDeployGuidance(body)
|
|
2300
|
+
...readDeployGuidance(body),
|
|
2301
|
+
...readAuditRefusal(body)
|
|
2302
|
+
};
|
|
2303
|
+
}
|
|
2304
|
+
function readAuditRefusal(body) {
|
|
2305
|
+
const holds = Array.isArray(body.holds) ? body.holds.flatMap((h) => isRecord2(h) && typeof h.flag === "string" ? [{
|
|
2306
|
+
flag: h.flag,
|
|
2307
|
+
...typeof h.path === "string" ? { path: h.path } : {},
|
|
2308
|
+
...typeof h.line === "number" ? { line: h.line } : {},
|
|
2309
|
+
...typeof h.host === "string" ? { host: h.host } : {}
|
|
2310
|
+
}] : []) : undefined;
|
|
2311
|
+
const served = Array.isArray(body.served_data_findings) ? body.served_data_findings.flatMap((f) => isRecord2(f) && typeof f.path === "string" && typeof f.rule === "string" ? [{ path: f.path, rule: f.rule, columns: readStringArray(f.columns) ?? [] }] : []) : undefined;
|
|
2312
|
+
return {
|
|
2313
|
+
...holds === undefined ? {} : { holds },
|
|
2314
|
+
...served === undefined ? {} : { served_data_findings: served },
|
|
2315
|
+
...typeof body.next_step === "string" ? { next_step: body.next_step } : {},
|
|
2316
|
+
...typeof body.review_url === "string" ? { review_url: body.review_url } : {}
|
|
2229
2317
|
};
|
|
2230
2318
|
}
|
|
2231
2319
|
function readDeployGuidance(body) {
|
|
@@ -2602,7 +2690,7 @@ import { join as join6 } from "node:path";
|
|
|
2602
2690
|
import { parse as parseYaml2 } from "yaml";
|
|
2603
2691
|
|
|
2604
2692
|
// ../launchpad-engine/dist/schema.js
|
|
2605
|
-
import { z as
|
|
2693
|
+
import { z as z4 } from "zod";
|
|
2606
2694
|
|
|
2607
2695
|
// ../launchpad-engine/dist/audience.js
|
|
2608
2696
|
import { z } from "zod";
|
|
@@ -2692,11 +2780,137 @@ ${entry.name}`;
|
|
|
2692
2780
|
}
|
|
2693
2781
|
});
|
|
2694
2782
|
|
|
2783
|
+
// ../launchpad-engine/dist/boundary.js
|
|
2784
|
+
import { z as z3 } from "zod";
|
|
2785
|
+
var ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
2786
|
+
function isIsoDate(s) {
|
|
2787
|
+
const m = ISO_DATE.exec(s);
|
|
2788
|
+
if (m === null)
|
|
2789
|
+
return false;
|
|
2790
|
+
const [y, mo, d] = [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
2791
|
+
const t = new Date(Date.UTC(y, mo - 1, d));
|
|
2792
|
+
return t.getUTCFullYear() === y && t.getUTCMonth() === mo - 1 && t.getUTCDate() === d;
|
|
2793
|
+
}
|
|
2794
|
+
var IsoDateSchema = z3.string().refine(isIsoDate, "must be a real date in YYYY-MM-DD form (quote it in YAML)");
|
|
2795
|
+
var BOUNDARY_TESTS = [
|
|
2796
|
+
"customer",
|
|
2797
|
+
"sales_agent",
|
|
2798
|
+
"financial_accounting",
|
|
2799
|
+
"sensitive_data",
|
|
2800
|
+
"system_of_record",
|
|
2801
|
+
"regulatory"
|
|
2802
|
+
];
|
|
2803
|
+
var DATA_CLASSIFICATIONS = [
|
|
2804
|
+
"general",
|
|
2805
|
+
"restricted",
|
|
2806
|
+
"confidential",
|
|
2807
|
+
"aggregated-from-restricted"
|
|
2808
|
+
];
|
|
2809
|
+
var PERSONAL_DATA_KINDS = [
|
|
2810
|
+
"none",
|
|
2811
|
+
"staff_work_contact",
|
|
2812
|
+
"staff_hr",
|
|
2813
|
+
"customer",
|
|
2814
|
+
"agent",
|
|
2815
|
+
"third_party"
|
|
2816
|
+
];
|
|
2817
|
+
var RESTRICTED_KINDS = [
|
|
2818
|
+
"compensation",
|
|
2819
|
+
"performance",
|
|
2820
|
+
"customer_personal",
|
|
2821
|
+
"customer_repayment",
|
|
2822
|
+
"device_identifier",
|
|
2823
|
+
"credit_or_bureau",
|
|
2824
|
+
"unreleased_financials",
|
|
2825
|
+
"security_findings",
|
|
2826
|
+
"credentials",
|
|
2827
|
+
"legal_matters",
|
|
2828
|
+
"other_designated"
|
|
2829
|
+
];
|
|
2830
|
+
var AUDIENCE_SCOPES = ["team", "function", "company"];
|
|
2831
|
+
var BOUNDARY_VERSION = 1;
|
|
2832
|
+
var ReasonSchema = z3.string().trim().min(10, "reason must be at least 10 characters").max(280);
|
|
2833
|
+
var TestAnswerSchema = z3.object({
|
|
2834
|
+
answer: z3.enum(["yes", "no"]),
|
|
2835
|
+
reason: ReasonSchema
|
|
2836
|
+
}).strict();
|
|
2837
|
+
var TestsSchema = z3.object(Object.fromEntries(BOUNDARY_TESTS.map((t) => [t, TestAnswerSchema]))).strict();
|
|
2838
|
+
var BOUNDARY_HOSTNAME_REGEX = /^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
|
|
2839
|
+
var HostnameSchema = z3.string().max(253).regex(BOUNDARY_HOSTNAME_REGEX, "host must be a lowercase DNS name (no scheme, port, path or wildcard)");
|
|
2840
|
+
function uniq(a) {
|
|
2841
|
+
return new Set(a).size === a.length;
|
|
2842
|
+
}
|
|
2843
|
+
var BoundaryDataSchema = z3.object({
|
|
2844
|
+
classification: z3.enum(DATA_CLASSIFICATIONS),
|
|
2845
|
+
personal_data: z3.array(z3.enum(PERSONAL_DATA_KINDS)).min(1, "personal_data must list at least one kind (use [none])").refine(uniq, "personal_data must not repeat"),
|
|
2846
|
+
record_level: z3.boolean(),
|
|
2847
|
+
restricted_kinds: z3.array(z3.enum(RESTRICTED_KINDS)).refine(uniq, "restricted_kinds must not repeat").optional(),
|
|
2848
|
+
aggregated_at: z3.enum(["source", "in_app"]).optional(),
|
|
2849
|
+
retention_days: z3.number().int().min(1).max(3650).optional()
|
|
2850
|
+
}).strict().superRefine((d, ctx) => {
|
|
2851
|
+
const kinds = d.restricted_kinds ?? [];
|
|
2852
|
+
if (d.classification === "general") {
|
|
2853
|
+
if (kinds.length > 0) {
|
|
2854
|
+
ctx.addIssue({ code: "custom", path: ["restricted_kinds"], message: "restricted_kinds must be empty when classification is general" });
|
|
2855
|
+
}
|
|
2856
|
+
} else if (kinds.length === 0) {
|
|
2857
|
+
ctx.addIssue({ code: "custom", path: ["restricted_kinds"], message: `restricted_kinds must list at least one kind when classification is ${d.classification}` });
|
|
2858
|
+
}
|
|
2859
|
+
if (d.classification === "aggregated-from-restricted") {
|
|
2860
|
+
if (d.aggregated_at === undefined) {
|
|
2861
|
+
ctx.addIssue({ code: "custom", path: ["aggregated_at"], message: "aggregated_at is required when classification is aggregated-from-restricted" });
|
|
2862
|
+
}
|
|
2863
|
+
} else if (d.aggregated_at !== undefined) {
|
|
2864
|
+
ctx.addIssue({ code: "custom", path: ["aggregated_at"], message: "aggregated_at is only allowed when classification is aggregated-from-restricted" });
|
|
2865
|
+
}
|
|
2866
|
+
if (d.personal_data.includes("none") && d.personal_data.length > 1) {
|
|
2867
|
+
ctx.addIssue({ code: "custom", path: ["personal_data"], message: "personal_data: none cannot be combined with other kinds" });
|
|
2868
|
+
}
|
|
2869
|
+
});
|
|
2870
|
+
var OutboundSchema = z3.object({
|
|
2871
|
+
host: HostnameSchema,
|
|
2872
|
+
access: z3.enum(["read", "write"]),
|
|
2873
|
+
purpose: z3.string().trim().min(5).max(140),
|
|
2874
|
+
production: z3.boolean()
|
|
2875
|
+
}).strict();
|
|
2876
|
+
var ProductionWriteSchema = z3.object({
|
|
2877
|
+
system: z3.string().trim().min(2).max(60),
|
|
2878
|
+
host: HostnameSchema
|
|
2879
|
+
}).strict();
|
|
2880
|
+
var BoundarySchema = z3.object({
|
|
2881
|
+
version: z3.literal(BOUNDARY_VERSION),
|
|
2882
|
+
declared_on: IsoDateSchema.optional(),
|
|
2883
|
+
review_by: IsoDateSchema.optional(),
|
|
2884
|
+
tests: TestsSchema.optional(),
|
|
2885
|
+
audience: z3.object({
|
|
2886
|
+
statement: z3.string().trim().min(10).max(280),
|
|
2887
|
+
scope: z3.enum(AUDIENCE_SCOPES)
|
|
2888
|
+
}).strict().optional(),
|
|
2889
|
+
data: BoundaryDataSchema,
|
|
2890
|
+
outbound: z3.array(OutboundSchema).max(50).optional(),
|
|
2891
|
+
production_writes: z3.array(ProductionWriteSchema).max(20).optional(),
|
|
2892
|
+
owners: z3.array(z3.string().email().max(254)).min(1).max(5).refine(uniq, "owners must not repeat").optional(),
|
|
2893
|
+
prototype: z3.boolean().optional(),
|
|
2894
|
+
retire_by: IsoDateSchema.optional()
|
|
2895
|
+
}).strict().superRefine((b, ctx) => {
|
|
2896
|
+
const hosts = (b.outbound ?? []).map((o) => `${o.host}
|
|
2897
|
+
${o.access}`);
|
|
2898
|
+
if (!uniq(hosts)) {
|
|
2899
|
+
ctx.addIssue({ code: "custom", path: ["outbound"], message: "outbound must not repeat the same host and access" });
|
|
2900
|
+
}
|
|
2901
|
+
});
|
|
2902
|
+
var UUID_REGEX = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
2903
|
+
var BroadAudienceAckSchema = z3.object({
|
|
2904
|
+
by: z3.string().trim().max(254).refine((s) => UUID_REGEX.test(s) || z3.string().email().safeParse(s).success, "by must be an Entra object id or a work email"),
|
|
2905
|
+
reason: ReasonSchema,
|
|
2906
|
+
expires: IsoDateSchema
|
|
2907
|
+
}).strict();
|
|
2908
|
+
|
|
2695
2909
|
// ../launchpad-engine/dist/schema.js
|
|
2696
2910
|
var APP_TYPES2 = ["static", "react", "react+api", "container"];
|
|
2697
2911
|
var AUTH_MODES = ["access", "gateway"];
|
|
2698
2912
|
var IDENTITY_TYPES = ["employee", "dsr"];
|
|
2699
|
-
var IdentityTypesSchema =
|
|
2913
|
+
var IdentityTypesSchema = z4.array(z4.enum(IDENTITY_TYPES)).min(1).refine((values) => new Set(values).size === values.length, {
|
|
2700
2914
|
message: "identity_types must not contain duplicates"
|
|
2701
2915
|
}).refine((values) => values.includes("employee"), {
|
|
2702
2916
|
message: "identity_types must include employee"
|
|
@@ -2708,36 +2922,37 @@ var PRIMARY_TARGET = "primary";
|
|
|
2708
2922
|
var SLUG_REGEX = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
|
|
2709
2923
|
var ENV_NAME_REGEX = /^[A-Z][A-Z0-9_]*$/;
|
|
2710
2924
|
var SESSION_DURATION_REGEX = /^[0-9]+(s|m|h)$/;
|
|
2711
|
-
var MetadataSchema =
|
|
2712
|
-
name:
|
|
2713
|
-
team:
|
|
2714
|
-
owner:
|
|
2715
|
-
description:
|
|
2925
|
+
var MetadataSchema = z4.object({
|
|
2926
|
+
name: z4.string().min(2).max(63).regex(SLUG_REGEX, "must be lowercase letters, digits, and hyphens; start/end alphanumeric"),
|
|
2927
|
+
team: z4.string().min(1),
|
|
2928
|
+
owner: z4.string().email(),
|
|
2929
|
+
description: z4.string().max(280).optional()
|
|
2716
2930
|
}).strict();
|
|
2717
|
-
var DeploymentSchema =
|
|
2718
|
-
type:
|
|
2719
|
-
runtime:
|
|
2931
|
+
var DeploymentSchema = z4.object({
|
|
2932
|
+
type: z4.enum(APP_TYPES2),
|
|
2933
|
+
runtime: z4.enum(RUNTIMES).optional()
|
|
2720
2934
|
}).strict();
|
|
2721
|
-
var AccessSchema =
|
|
2722
|
-
audience:
|
|
2935
|
+
var AccessSchema = z4.object({
|
|
2936
|
+
audience: z4.literal("private").optional(),
|
|
2723
2937
|
private_owner: PrivateOwnerSchema.optional(),
|
|
2724
|
-
allowed_entra_group:
|
|
2725
|
-
allowed_entra_groups:
|
|
2726
|
-
session_duration:
|
|
2727
|
-
identity_types: IdentityTypesSchema.optional()
|
|
2938
|
+
allowed_entra_group: z4.string().min(1).optional(),
|
|
2939
|
+
allowed_entra_groups: z4.array(z4.string().min(1)).refine((arr) => new Set(arr).size === arr.length, { message: "allowed_entra_groups must not contain duplicates" }).optional(),
|
|
2940
|
+
session_duration: z4.string().regex(SESSION_DURATION_REGEX, "must match Go duration format, e.g. 24h / 30m / 60s").optional(),
|
|
2941
|
+
identity_types: IdentityTypesSchema.optional(),
|
|
2942
|
+
broad_audience_ack: BroadAudienceAckSchema.optional()
|
|
2728
2943
|
}).strict().superRefine((access, ctx) => {
|
|
2729
2944
|
const hasSingular = access.allowed_entra_group !== undefined;
|
|
2730
2945
|
const hasPlural = access.allowed_entra_groups !== undefined;
|
|
2731
2946
|
if (!hasSingular && !hasPlural && access.audience !== "private") {
|
|
2732
2947
|
ctx.addIssue({
|
|
2733
|
-
code:
|
|
2948
|
+
code: z4.ZodIssueCode.custom,
|
|
2734
2949
|
message: "either `allowed_entra_group` (singular, legacy) or `allowed_entra_groups` (plural, preferred) must be set",
|
|
2735
2950
|
path: ["allowed_entra_groups"]
|
|
2736
2951
|
});
|
|
2737
2952
|
}
|
|
2738
2953
|
if (hasSingular && hasPlural) {
|
|
2739
2954
|
ctx.addIssue({
|
|
2740
|
-
code:
|
|
2955
|
+
code: z4.ZodIssueCode.custom,
|
|
2741
2956
|
message: "`allowed_entra_group` (singular) and `allowed_entra_groups` (plural) are mutually exclusive; use the plural form",
|
|
2742
2957
|
path: ["allowed_entra_groups"]
|
|
2743
2958
|
});
|
|
@@ -2751,73 +2966,74 @@ function allowedEntraGroups(access) {
|
|
|
2751
2966
|
}
|
|
2752
2967
|
return [access.allowed_entra_group];
|
|
2753
2968
|
}
|
|
2754
|
-
var ContainerSchema =
|
|
2755
|
-
name:
|
|
2756
|
-
image:
|
|
2757
|
-
port:
|
|
2758
|
-
ingress:
|
|
2759
|
-
healthcheck:
|
|
2760
|
-
env:
|
|
2761
|
-
max_instances:
|
|
2969
|
+
var ContainerSchema = z4.object({
|
|
2970
|
+
name: z4.string().min(2).max(32).regex(SLUG_REGEX, "container name must be lowercase letters, digits, and hyphens"),
|
|
2971
|
+
image: z4.string().min(1),
|
|
2972
|
+
port: z4.number().int().min(1).max(65535),
|
|
2973
|
+
ingress: z4.boolean().optional(),
|
|
2974
|
+
healthcheck: z4.string().default("/health"),
|
|
2975
|
+
env: z4.array(z4.string().regex(ENV_NAME_REGEX, "env entries must be UPPER_SNAKE_CASE")).optional(),
|
|
2976
|
+
max_instances: z4.number().int().min(1).max(100).optional()
|
|
2762
2977
|
}).strict();
|
|
2763
|
-
var TargetSchema =
|
|
2764
|
-
kind:
|
|
2765
|
-
script:
|
|
2766
|
-
schedule:
|
|
2767
|
-
d1_binding:
|
|
2978
|
+
var TargetSchema = z4.object({
|
|
2979
|
+
kind: z4.enum(TARGET_KINDS),
|
|
2980
|
+
script: z4.string().min(2).max(63).regex(SLUG_REGEX, "target script must be lowercase letters, digits, and hyphens").optional(),
|
|
2981
|
+
schedule: z4.array(z4.string().min(1).max(120)).min(1).max(20).optional(),
|
|
2982
|
+
d1_binding: z4.string().min(1).max(64).regex(ENV_NAME_REGEX, "d1_binding must be an UPPER_SNAKE_CASE binding name").optional()
|
|
2768
2983
|
}).strict();
|
|
2769
|
-
var SecretBindingSchema =
|
|
2770
|
-
name:
|
|
2771
|
-
source:
|
|
2772
|
-
description:
|
|
2773
|
-
targets:
|
|
2984
|
+
var SecretBindingSchema = z4.object({
|
|
2985
|
+
name: z4.string().min(1).max(64).regex(ENV_NAME_REGEX, "secret binding name must be UPPER_SNAKE_CASE"),
|
|
2986
|
+
source: z4.enum(SECRET_SOURCES),
|
|
2987
|
+
description: z4.string().max(200).optional(),
|
|
2988
|
+
targets: z4.union([z4.literal("all"), z4.array(z4.string().min(1)).min(1)]).optional()
|
|
2774
2989
|
}).strict();
|
|
2775
|
-
var SecretsSchema =
|
|
2776
|
-
bindings:
|
|
2990
|
+
var SecretsSchema = z4.object({
|
|
2991
|
+
bindings: z4.array(SecretBindingSchema).optional()
|
|
2777
2992
|
}).strict();
|
|
2778
|
-
var BuildSchema =
|
|
2779
|
-
command:
|
|
2780
|
-
destination_dir:
|
|
2781
|
-
root_dir:
|
|
2993
|
+
var BuildSchema = z4.object({
|
|
2994
|
+
command: z4.string().min(1).optional(),
|
|
2995
|
+
destination_dir: z4.string().min(1),
|
|
2996
|
+
root_dir: z4.string()
|
|
2782
2997
|
}).strict();
|
|
2783
2998
|
var STATIC_SERVE_DIR = "static";
|
|
2784
2999
|
function staticNoBuild() {
|
|
2785
3000
|
return { destination_dir: STATIC_SERVE_DIR, root_dir: "" };
|
|
2786
3001
|
}
|
|
2787
|
-
var AppBoundarySchema =
|
|
2788
|
-
root:
|
|
2789
|
-
include:
|
|
2790
|
-
exclude:
|
|
3002
|
+
var AppBoundarySchema = z4.object({
|
|
3003
|
+
root: z4.string().min(1).optional(),
|
|
3004
|
+
include: z4.array(z4.string().min(1)).min(1).optional(),
|
|
3005
|
+
exclude: z4.array(z4.string().min(1)).optional()
|
|
2791
3006
|
}).strict();
|
|
2792
|
-
var ProductionEnvSchema =
|
|
2793
|
-
var VerifySchema =
|
|
2794
|
-
protected_path:
|
|
3007
|
+
var ProductionEnvSchema = z4.record(z4.string().regex(ENV_NAME_REGEX, "production_env keys must be UPPER_SNAKE_CASE"), z4.string());
|
|
3008
|
+
var VerifySchema = z4.object({
|
|
3009
|
+
protected_path: z4.string().min(1).regex(/^\//, "verify.protected_path must be a root-relative path beginning with '/'")
|
|
2795
3010
|
}).strict();
|
|
2796
|
-
var ManifestSchema =
|
|
2797
|
-
apiVersion:
|
|
2798
|
-
kind:
|
|
3011
|
+
var ManifestSchema = z4.object({
|
|
3012
|
+
apiVersion: z4.literal("launchpad.m-kopa.us/v1alpha1"),
|
|
3013
|
+
kind: z4.literal("App"),
|
|
2799
3014
|
metadata: MetadataSchema,
|
|
2800
3015
|
deployment: DeploymentSchema,
|
|
2801
3016
|
access: AccessSchema,
|
|
2802
|
-
auth:
|
|
2803
|
-
hostnames:
|
|
2804
|
-
containers:
|
|
3017
|
+
auth: z4.enum(AUTH_MODES).optional(),
|
|
3018
|
+
hostnames: z4.array(z4.string().min(1)).optional(),
|
|
3019
|
+
containers: z4.array(ContainerSchema).min(1).optional(),
|
|
2805
3020
|
secrets: SecretsSchema.optional(),
|
|
2806
|
-
targets:
|
|
3021
|
+
targets: z4.array(TargetSchema).optional(),
|
|
2807
3022
|
build: BuildSchema.optional(),
|
|
2808
3023
|
production_env: ProductionEnvSchema.optional(),
|
|
2809
3024
|
app: AppBoundarySchema.optional(),
|
|
2810
3025
|
verify: VerifySchema.optional(),
|
|
2811
|
-
confine_origin:
|
|
2812
|
-
origin:
|
|
2813
|
-
catalogue:
|
|
2814
|
-
sensitive:
|
|
2815
|
-
integrations: IntegrationsSchema.optional()
|
|
3026
|
+
confine_origin: z4.boolean().optional(),
|
|
3027
|
+
origin: z4.enum(["pages", "dispatch"]).optional(),
|
|
3028
|
+
catalogue: z4.object({ listed: z4.boolean().default(true) }).strict().optional(),
|
|
3029
|
+
sensitive: z4.boolean().optional(),
|
|
3030
|
+
integrations: IntegrationsSchema.optional(),
|
|
3031
|
+
boundary: BoundarySchema.optional()
|
|
2816
3032
|
}).strict().superRefine((m, ctx) => {
|
|
2817
3033
|
const isContainer = m.deployment.type === "container";
|
|
2818
3034
|
if (m.access.identity_types !== undefined && (m.auth ?? "access") !== "gateway") {
|
|
2819
3035
|
ctx.addIssue({
|
|
2820
|
-
code:
|
|
3036
|
+
code: z4.ZodIssueCode.custom,
|
|
2821
3037
|
path: ["access", "identity_types"],
|
|
2822
3038
|
message: "access.identity_types is only valid with auth: gateway"
|
|
2823
3039
|
});
|
|
@@ -2825,19 +3041,19 @@ var ManifestSchema = z3.object({
|
|
|
2825
3041
|
if (m.confine_origin !== undefined) {
|
|
2826
3042
|
if (isContainer) {
|
|
2827
3043
|
ctx.addIssue({
|
|
2828
|
-
code:
|
|
3044
|
+
code: z4.ZodIssueCode.custom,
|
|
2829
3045
|
path: ["confine_origin"],
|
|
2830
3046
|
message: "confine_origin is only valid for gateway pages apps (static/react/react+api); container apps have no pages.dev surface."
|
|
2831
3047
|
});
|
|
2832
3048
|
} else if (m.auth === "access") {
|
|
2833
3049
|
ctx.addIssue({
|
|
2834
|
-
code:
|
|
3050
|
+
code: z4.ZodIssueCode.custom,
|
|
2835
3051
|
path: ["confine_origin"],
|
|
2836
3052
|
message: "confine_origin applies to gateway-fronted apps (auth: gateway); it has no meaning under Cloudflare Access."
|
|
2837
3053
|
});
|
|
2838
3054
|
} else if (m.deployment.type === "static" && m.confine_origin === false) {
|
|
2839
3055
|
ctx.addIssue({
|
|
2840
|
-
code:
|
|
3056
|
+
code: z4.ZodIssueCode.custom,
|
|
2841
3057
|
path: ["confine_origin"],
|
|
2842
3058
|
message: "confine_origin: false is not allowed for static apps — they have no verifier, so an unconfined apex would be world-readable (ADR 0031)."
|
|
2843
3059
|
});
|
|
@@ -2845,35 +3061,35 @@ var ManifestSchema = z3.object({
|
|
|
2845
3061
|
}
|
|
2846
3062
|
if (isContainer && m.containers === undefined) {
|
|
2847
3063
|
ctx.addIssue({
|
|
2848
|
-
code:
|
|
3064
|
+
code: z4.ZodIssueCode.custom,
|
|
2849
3065
|
path: ["containers"],
|
|
2850
3066
|
message: "containers[] is required when deployment.type is 'container'"
|
|
2851
3067
|
});
|
|
2852
3068
|
}
|
|
2853
3069
|
if (!isContainer && m.containers !== undefined) {
|
|
2854
3070
|
ctx.addIssue({
|
|
2855
|
-
code:
|
|
3071
|
+
code: z4.ZodIssueCode.custom,
|
|
2856
3072
|
path: ["containers"],
|
|
2857
3073
|
message: `containers[] is only allowed when deployment.type is 'container' (current type: '${m.deployment.type}')`
|
|
2858
3074
|
});
|
|
2859
3075
|
}
|
|
2860
3076
|
if (!isContainer && m.deployment.runtime !== undefined) {
|
|
2861
3077
|
ctx.addIssue({
|
|
2862
|
-
code:
|
|
3078
|
+
code: z4.ZodIssueCode.custom,
|
|
2863
3079
|
path: ["deployment", "runtime"],
|
|
2864
3080
|
message: "deployment.runtime is only meaningful when deployment.type is 'container'"
|
|
2865
3081
|
});
|
|
2866
3082
|
}
|
|
2867
3083
|
if (isContainer && m.build !== undefined) {
|
|
2868
3084
|
ctx.addIssue({
|
|
2869
|
-
code:
|
|
3085
|
+
code: z4.ZodIssueCode.custom,
|
|
2870
3086
|
path: ["build"],
|
|
2871
3087
|
message: "build is only allowed for pages-app deployments (static/react/react+api). Container builds live in the Dockerfile."
|
|
2872
3088
|
});
|
|
2873
3089
|
}
|
|
2874
3090
|
if (isContainer && m.production_env !== undefined) {
|
|
2875
3091
|
ctx.addIssue({
|
|
2876
|
-
code:
|
|
3092
|
+
code: z4.ZodIssueCode.custom,
|
|
2877
3093
|
path: ["production_env"],
|
|
2878
3094
|
message: "production_env is only allowed for pages-app deployments. Container env vars use containers[].env (names only) + the bot's secrets pipeline for values."
|
|
2879
3095
|
});
|
|
@@ -2882,7 +3098,7 @@ var ManifestSchema = z3.object({
|
|
|
2882
3098
|
const ingressContainers = m.containers.filter((c) => c.ingress === true);
|
|
2883
3099
|
if (ingressContainers.length !== 1) {
|
|
2884
3100
|
ctx.addIssue({
|
|
2885
|
-
code:
|
|
3101
|
+
code: z4.ZodIssueCode.custom,
|
|
2886
3102
|
path: ["containers"],
|
|
2887
3103
|
message: `multi-container apps must mark exactly one container ingress: true (found ${ingressContainers.length})`
|
|
2888
3104
|
});
|
|
@@ -2895,7 +3111,7 @@ var ManifestSchema = z3.object({
|
|
|
2895
3111
|
for (const envName of c.env ?? []) {
|
|
2896
3112
|
if (!declaredBindings.has(envName)) {
|
|
2897
3113
|
ctx.addIssue({
|
|
2898
|
-
code:
|
|
3114
|
+
code: z4.ZodIssueCode.custom,
|
|
2899
3115
|
path: ["containers", i, "env"],
|
|
2900
3116
|
message: `env reference '${envName}' has no matching entry in secrets.bindings[]`
|
|
2901
3117
|
});
|
|
@@ -2911,7 +3127,7 @@ var ManifestSchema = z3.object({
|
|
|
2911
3127
|
continue;
|
|
2912
3128
|
if (seen.has(name)) {
|
|
2913
3129
|
ctx.addIssue({
|
|
2914
|
-
code:
|
|
3130
|
+
code: z4.ZodIssueCode.custom,
|
|
2915
3131
|
path: ["containers", i, "name"],
|
|
2916
3132
|
message: `duplicate container name '${name}' — names become DO class identifiers and must be unique`
|
|
2917
3133
|
});
|
|
@@ -2928,7 +3144,7 @@ var ManifestSchema = z3.object({
|
|
|
2928
3144
|
continue;
|
|
2929
3145
|
if (seen.has(name)) {
|
|
2930
3146
|
ctx.addIssue({
|
|
2931
|
-
code:
|
|
3147
|
+
code: z4.ZodIssueCode.custom,
|
|
2932
3148
|
path: ["secrets", "bindings", i, "name"],
|
|
2933
3149
|
message: `duplicate secret binding name '${name}' — names become env-var keys and must be unique`
|
|
2934
3150
|
});
|
|
@@ -2941,21 +3157,21 @@ var ManifestSchema = z3.object({
|
|
|
2941
3157
|
const t = targets[i];
|
|
2942
3158
|
if (t.kind === "worker" && t.script === undefined) {
|
|
2943
3159
|
ctx.addIssue({
|
|
2944
|
-
code:
|
|
3160
|
+
code: z4.ZodIssueCode.custom,
|
|
2945
3161
|
path: ["targets", i, "script"],
|
|
2946
3162
|
message: "a worker target must declare a script (the sibling Workers script name)"
|
|
2947
3163
|
});
|
|
2948
3164
|
}
|
|
2949
3165
|
if (t.kind === "pages" && t.script !== undefined) {
|
|
2950
3166
|
ctx.addIssue({
|
|
2951
|
-
code:
|
|
3167
|
+
code: z4.ZodIssueCode.custom,
|
|
2952
3168
|
path: ["targets", i, "script"],
|
|
2953
3169
|
message: "a pages target must not declare a script — the primary Pages project is the app slug"
|
|
2954
3170
|
});
|
|
2955
3171
|
}
|
|
2956
3172
|
if (t.kind === "pages" && t.schedule !== undefined) {
|
|
2957
3173
|
ctx.addIssue({
|
|
2958
|
-
code:
|
|
3174
|
+
code: z4.ZodIssueCode.custom,
|
|
2959
3175
|
path: ["targets", i, "schedule"],
|
|
2960
3176
|
message: "schedule is only valid on a worker target (the cron deploy contract — ADR 0022)"
|
|
2961
3177
|
});
|
|
@@ -2969,7 +3185,7 @@ var ManifestSchema = z3.object({
|
|
|
2969
3185
|
pagesTargets++;
|
|
2970
3186
|
if (pagesTargets > 1) {
|
|
2971
3187
|
ctx.addIssue({
|
|
2972
|
-
code:
|
|
3188
|
+
code: z4.ZodIssueCode.custom,
|
|
2973
3189
|
path: ["targets", i, "kind"],
|
|
2974
3190
|
message: "at most one pages target may be declared (the primary Pages project is singular)"
|
|
2975
3191
|
});
|
|
@@ -2980,7 +3196,7 @@ var ManifestSchema = z3.object({
|
|
|
2980
3196
|
continue;
|
|
2981
3197
|
if (t.script === PRIMARY_TARGET || t.script === "pages") {
|
|
2982
3198
|
ctx.addIssue({
|
|
2983
|
-
code:
|
|
3199
|
+
code: z4.ZodIssueCode.custom,
|
|
2984
3200
|
path: ["targets", i, "script"],
|
|
2985
3201
|
message: `worker target script '${t.script}' is a reserved selector token — use a different script name`
|
|
2986
3202
|
});
|
|
@@ -2988,7 +3204,7 @@ var ManifestSchema = z3.object({
|
|
|
2988
3204
|
}
|
|
2989
3205
|
if (seenScripts.has(t.script)) {
|
|
2990
3206
|
ctx.addIssue({
|
|
2991
|
-
code:
|
|
3207
|
+
code: z4.ZodIssueCode.custom,
|
|
2992
3208
|
path: ["targets", i, "script"],
|
|
2993
3209
|
message: `duplicate worker target script '${t.script}' — target scripts must be unique`
|
|
2994
3210
|
});
|
|
@@ -3006,7 +3222,7 @@ var ManifestSchema = z3.object({
|
|
|
3006
3222
|
for (const ref of sel) {
|
|
3007
3223
|
if (!validRefs.has(ref)) {
|
|
3008
3224
|
ctx.addIssue({
|
|
3009
|
-
code:
|
|
3225
|
+
code: z4.ZodIssueCode.custom,
|
|
3010
3226
|
path: ["secrets", "bindings", bi, "targets"],
|
|
3011
3227
|
message: `secret binding '${b?.name}' references unknown target '${ref}' — declare it in targets[] or use "primary"`
|
|
3012
3228
|
});
|
|
@@ -3422,51 +3638,57 @@ var STATUS_STATUS_KEYS = new Set([
|
|
|
3422
3638
|
"status.generated_at"
|
|
3423
3639
|
]);
|
|
3424
3640
|
// ../launchpad-engine/dist/schema-v2.js
|
|
3425
|
-
import { z as
|
|
3426
|
-
var EnvVarSchema =
|
|
3427
|
-
|
|
3428
|
-
|
|
3641
|
+
import { z as z5 } from "zod";
|
|
3642
|
+
var EnvVarSchema = z5.discriminatedUnion("type", [
|
|
3643
|
+
z5.object({ type: z5.literal("secret_text"), secret_ref: z5.string().min(1) }).strict(),
|
|
3644
|
+
z5.object({ type: z5.literal("plain_text"), value: z5.string() }).strict()
|
|
3429
3645
|
]);
|
|
3430
3646
|
var MIGRATION_STAGES = ["staged", "flipped"];
|
|
3431
|
-
var SpecSchema =
|
|
3432
|
-
appType:
|
|
3433
|
-
display:
|
|
3434
|
-
name:
|
|
3435
|
-
description:
|
|
3436
|
-
team:
|
|
3647
|
+
var SpecSchema = z5.object({
|
|
3648
|
+
appType: z5.enum(APP_TYPES2),
|
|
3649
|
+
display: z5.object({
|
|
3650
|
+
name: z5.string().min(1),
|
|
3651
|
+
description: z5.string().max(280).optional(),
|
|
3652
|
+
team: z5.string().min(1)
|
|
3437
3653
|
}).strict(),
|
|
3438
|
-
owner:
|
|
3439
|
-
access:
|
|
3440
|
-
audience:
|
|
3654
|
+
owner: z5.object({ email: z5.string().email() }).strict(),
|
|
3655
|
+
access: z5.object({
|
|
3656
|
+
audience: z5.literal("private").optional(),
|
|
3441
3657
|
private_owner: PrivateOwnerSchema.optional(),
|
|
3442
|
-
allowed_entra_groups:
|
|
3658
|
+
allowed_entra_groups: z5.array(z5.string().min(1)).refine((a) => new Set(a).size === a.length, {
|
|
3443
3659
|
message: "allowed_entra_groups must not contain duplicates"
|
|
3444
3660
|
}),
|
|
3445
|
-
require_email_domain:
|
|
3446
|
-
identity_types: IdentityTypesSchema.optional()
|
|
3661
|
+
require_email_domain: z5.string().min(1).optional(),
|
|
3662
|
+
identity_types: IdentityTypesSchema.optional(),
|
|
3663
|
+
broad_audience_ack: BroadAudienceAckSchema.optional()
|
|
3447
3664
|
}).strict().superRefine(validateAudience),
|
|
3448
|
-
auth:
|
|
3665
|
+
auth: z5.enum(AUTH_MODES).optional(),
|
|
3449
3666
|
build: BuildSchema.optional(),
|
|
3450
3667
|
app: AppBoundarySchema.optional(),
|
|
3451
3668
|
verify: VerifySchema.optional(),
|
|
3452
|
-
confine_origin:
|
|
3453
|
-
origin:
|
|
3454
|
-
sensitive:
|
|
3669
|
+
confine_origin: z5.boolean().optional(),
|
|
3670
|
+
origin: z5.enum(["pages", "dispatch"]).optional(),
|
|
3671
|
+
sensitive: z5.boolean().optional(),
|
|
3672
|
+
lifecycle: z5.object({
|
|
3673
|
+
disabled: z5.boolean(),
|
|
3674
|
+
reason: z5.string().regex(/^[A-Za-z0-9 ._:#/-]{1,120}$/, "lifecycle.reason must be a ticket reference").optional()
|
|
3675
|
+
}).strict().optional(),
|
|
3455
3676
|
integrations: IntegrationsSchema.optional(),
|
|
3456
|
-
catalogue:
|
|
3457
|
-
env_vars:
|
|
3458
|
-
containers:
|
|
3677
|
+
catalogue: z5.object({ listed: z5.boolean().default(true) }).strict().optional(),
|
|
3678
|
+
env_vars: z5.record(z5.string().regex(ENV_NAME_REGEX, "env_vars keys must be UPPER_SNAKE_CASE"), EnvVarSchema).optional(),
|
|
3679
|
+
containers: z5.array(ContainerSchema).min(1).optional(),
|
|
3459
3680
|
secrets: SecretsSchema.optional(),
|
|
3460
|
-
fronted_by_concierge:
|
|
3461
|
-
migration:
|
|
3462
|
-
bindings:
|
|
3463
|
-
d1:
|
|
3681
|
+
fronted_by_concierge: z5.boolean().optional(),
|
|
3682
|
+
migration: z5.object({ stage: z5.enum(MIGRATION_STAGES) }).strict().optional(),
|
|
3683
|
+
bindings: z5.object({
|
|
3684
|
+
d1: z5.string().min(1).max(64).regex(ENV_NAME_REGEX, "bindings.d1 must be an UPPER_SNAKE_CASE binding name").optional()
|
|
3464
3685
|
}).strict().optional(),
|
|
3465
|
-
targets:
|
|
3686
|
+
targets: z5.array(TargetSchema).min(1).max(1).optional(),
|
|
3687
|
+
boundary: BoundarySchema.optional()
|
|
3466
3688
|
}).strict().superRefine((s, ctx) => {
|
|
3467
3689
|
if (s.access.identity_types !== undefined && (s.auth ?? "access") !== "gateway") {
|
|
3468
3690
|
ctx.addIssue({
|
|
3469
|
-
code:
|
|
3691
|
+
code: z5.ZodIssueCode.custom,
|
|
3470
3692
|
path: ["access", "identity_types"],
|
|
3471
3693
|
message: "access.identity_types is only valid with auth: gateway"
|
|
3472
3694
|
});
|
|
@@ -3474,7 +3696,7 @@ var SpecSchema = z4.object({
|
|
|
3474
3696
|
for (const [k, v] of Object.entries(s.env_vars ?? {})) {
|
|
3475
3697
|
if (/_(TOKEN|SECRET)$/.test(k) && v.type !== "secret_text") {
|
|
3476
3698
|
ctx.addIssue({
|
|
3477
|
-
code:
|
|
3699
|
+
code: z5.ZodIssueCode.custom,
|
|
3478
3700
|
path: ["env_vars", k],
|
|
3479
3701
|
message: `env var '${k}' is secret-bearing (*_TOKEN/*_SECRET) and must be type secret_text, not '${v.type}'`
|
|
3480
3702
|
});
|
|
@@ -3483,7 +3705,7 @@ var SpecSchema = z4.object({
|
|
|
3483
3705
|
const isContainer = s.appType === "container";
|
|
3484
3706
|
if (isContainer && s.containers === undefined) {
|
|
3485
3707
|
ctx.addIssue({
|
|
3486
|
-
code:
|
|
3708
|
+
code: z5.ZodIssueCode.custom,
|
|
3487
3709
|
path: ["containers"],
|
|
3488
3710
|
message: "containers[] is required when appType is 'container'"
|
|
3489
3711
|
});
|
|
@@ -3491,19 +3713,19 @@ var SpecSchema = z4.object({
|
|
|
3491
3713
|
if (s.confine_origin !== undefined) {
|
|
3492
3714
|
if (isContainer) {
|
|
3493
3715
|
ctx.addIssue({
|
|
3494
|
-
code:
|
|
3716
|
+
code: z5.ZodIssueCode.custom,
|
|
3495
3717
|
path: ["confine_origin"],
|
|
3496
3718
|
message: "confine_origin is only valid for gateway pages apps; container apps have no pages.dev surface."
|
|
3497
3719
|
});
|
|
3498
3720
|
} else if (s.auth === "access") {
|
|
3499
3721
|
ctx.addIssue({
|
|
3500
|
-
code:
|
|
3722
|
+
code: z5.ZodIssueCode.custom,
|
|
3501
3723
|
path: ["confine_origin"],
|
|
3502
3724
|
message: "confine_origin applies to gateway-fronted apps (auth: gateway); it has no meaning under Cloudflare Access."
|
|
3503
3725
|
});
|
|
3504
3726
|
} else if (s.appType === "static" && s.confine_origin === false) {
|
|
3505
3727
|
ctx.addIssue({
|
|
3506
|
-
code:
|
|
3728
|
+
code: z5.ZodIssueCode.custom,
|
|
3507
3729
|
path: ["confine_origin"],
|
|
3508
3730
|
message: "confine_origin: false is not allowed for static apps — an unconfined apex with no verifier is world-readable (ADR 0031)."
|
|
3509
3731
|
});
|
|
@@ -3512,21 +3734,21 @@ var SpecSchema = z4.object({
|
|
|
3512
3734
|
if (s.origin === "dispatch") {
|
|
3513
3735
|
if (isContainer) {
|
|
3514
3736
|
ctx.addIssue({
|
|
3515
|
-
code:
|
|
3737
|
+
code: z5.ZodIssueCode.custom,
|
|
3516
3738
|
path: ["origin"],
|
|
3517
3739
|
message: "origin: dispatch is not available for container apps — they run on the container runtime (ADR 0015/0016), not in a Workers dispatch namespace."
|
|
3518
3740
|
});
|
|
3519
3741
|
}
|
|
3520
3742
|
if ((s.auth ?? "access") !== "gateway") {
|
|
3521
3743
|
ctx.addIssue({
|
|
3522
|
-
code:
|
|
3744
|
+
code: z5.ZodIssueCode.custom,
|
|
3523
3745
|
path: ["origin"],
|
|
3524
3746
|
message: "origin: dispatch requires an explicit auth: gateway (auth defaults to 'access' when omitted). A dispatch-namespace Worker has no public hostname for Cloudflare Access to gate, so the gateway must be the sole gate."
|
|
3525
3747
|
});
|
|
3526
3748
|
}
|
|
3527
3749
|
if (s.confine_origin !== undefined && s.migration === undefined) {
|
|
3528
3750
|
ctx.addIssue({
|
|
3529
|
-
code:
|
|
3751
|
+
code: z5.ZodIssueCode.custom,
|
|
3530
3752
|
path: ["confine_origin"],
|
|
3531
3753
|
message: "confine_origin has no meaning with origin: dispatch — there is no public pages.dev apex to confine. Remove it."
|
|
3532
3754
|
});
|
|
@@ -3535,14 +3757,14 @@ var SpecSchema = z4.object({
|
|
|
3535
3757
|
if (s.migration !== undefined) {
|
|
3536
3758
|
if (s.origin !== "dispatch") {
|
|
3537
3759
|
ctx.addIssue({
|
|
3538
|
-
code:
|
|
3760
|
+
code: z5.ZodIssueCode.custom,
|
|
3539
3761
|
path: ["migration"],
|
|
3540
3762
|
message: "migration is only valid with origin: dispatch; the portal-bot writes it while moving a live app."
|
|
3541
3763
|
});
|
|
3542
3764
|
}
|
|
3543
3765
|
if (s.appType !== "static" && s.appType !== "react" && s.appType !== "react+api") {
|
|
3544
3766
|
ctx.addIssue({
|
|
3545
|
-
code:
|
|
3767
|
+
code: z5.ZodIssueCode.custom,
|
|
3546
3768
|
path: ["migration"],
|
|
3547
3769
|
message: `migration is only valid for static, react and react+api apps (current appType: '${s.appType}')`
|
|
3548
3770
|
});
|
|
@@ -3551,20 +3773,20 @@ var SpecSchema = z4.object({
|
|
|
3551
3773
|
if (s.bindings?.d1 !== undefined) {
|
|
3552
3774
|
if (s.origin !== "dispatch") {
|
|
3553
3775
|
ctx.addIssue({
|
|
3554
|
-
code:
|
|
3776
|
+
code: z5.ZodIssueCode.custom,
|
|
3555
3777
|
path: ["bindings", "d1"],
|
|
3556
3778
|
message: "bindings.d1 requires origin: dispatch. A pages-origin app declares its database with a v1 pages target d1_binding."
|
|
3557
3779
|
});
|
|
3558
3780
|
} else if (s.appType !== "react+api") {
|
|
3559
3781
|
ctx.addIssue({
|
|
3560
|
-
code:
|
|
3782
|
+
code: z5.ZodIssueCode.custom,
|
|
3561
3783
|
path: ["bindings", "d1"],
|
|
3562
3784
|
message: `bindings.d1 requires appType 'react+api' (current appType: '${s.appType}'); only a react+api app ships the Worker code that can read a database.`
|
|
3563
3785
|
});
|
|
3564
3786
|
}
|
|
3565
3787
|
if (s.env_vars?.[s.bindings.d1] !== undefined) {
|
|
3566
3788
|
ctx.addIssue({
|
|
3567
|
-
code:
|
|
3789
|
+
code: z5.ZodIssueCode.custom,
|
|
3568
3790
|
path: ["env_vars", s.bindings.d1],
|
|
3569
3791
|
message: `env var '${s.bindings.d1}' has the same name as bindings.d1. Rename one of them.`
|
|
3570
3792
|
});
|
|
@@ -3573,7 +3795,7 @@ var SpecSchema = z4.object({
|
|
|
3573
3795
|
if (s.targets !== undefined) {
|
|
3574
3796
|
if (s.origin !== "dispatch") {
|
|
3575
3797
|
ctx.addIssue({
|
|
3576
|
-
code:
|
|
3798
|
+
code: z5.ZodIssueCode.custom,
|
|
3577
3799
|
path: ["targets"],
|
|
3578
3800
|
message: "targets requires origin: dispatch. A pages-origin app declares its cron Worker in a v1 manifest."
|
|
3579
3801
|
});
|
|
@@ -3582,7 +3804,7 @@ var SpecSchema = z4.object({
|
|
|
3582
3804
|
const t = s.targets[i];
|
|
3583
3805
|
if (t.kind !== "worker") {
|
|
3584
3806
|
ctx.addIssue({
|
|
3585
|
-
code:
|
|
3807
|
+
code: z5.ZodIssueCode.custom,
|
|
3586
3808
|
path: ["targets", i, "kind"],
|
|
3587
3809
|
message: "a dispatch app has no Pages project, so the only valid target kind is 'worker' (the cron sibling Worker)"
|
|
3588
3810
|
});
|
|
@@ -3590,27 +3812,27 @@ var SpecSchema = z4.object({
|
|
|
3590
3812
|
}
|
|
3591
3813
|
if (t.script === undefined) {
|
|
3592
3814
|
ctx.addIssue({
|
|
3593
|
-
code:
|
|
3815
|
+
code: z5.ZodIssueCode.custom,
|
|
3594
3816
|
path: ["targets", i, "script"],
|
|
3595
3817
|
message: "a worker target must declare a script (the sibling Workers script name)"
|
|
3596
3818
|
});
|
|
3597
3819
|
} else if (t.script === PRIMARY_TARGET || t.script === "pages") {
|
|
3598
3820
|
ctx.addIssue({
|
|
3599
|
-
code:
|
|
3821
|
+
code: z5.ZodIssueCode.custom,
|
|
3600
3822
|
path: ["targets", i, "script"],
|
|
3601
3823
|
message: `worker target script '${t.script}' is a reserved selector token — use a different script name`
|
|
3602
3824
|
});
|
|
3603
3825
|
}
|
|
3604
3826
|
if (t.schedule === undefined) {
|
|
3605
3827
|
ctx.addIssue({
|
|
3606
|
-
code:
|
|
3828
|
+
code: z5.ZodIssueCode.custom,
|
|
3607
3829
|
path: ["targets", i, "schedule"],
|
|
3608
3830
|
message: "a dispatch worker target must declare a non-empty schedule; the cron sibling is the only thing spec.targets carries on dispatch"
|
|
3609
3831
|
});
|
|
3610
3832
|
}
|
|
3611
3833
|
if (t.d1_binding !== undefined) {
|
|
3612
3834
|
ctx.addIssue({
|
|
3613
|
-
code:
|
|
3835
|
+
code: z5.ZodIssueCode.custom,
|
|
3614
3836
|
path: ["targets", i, "d1_binding"],
|
|
3615
3837
|
message: "d1_binding is not supported on a dispatch worker target. Declare the app's database with bindings.d1."
|
|
3616
3838
|
});
|
|
@@ -3619,86 +3841,86 @@ var SpecSchema = z4.object({
|
|
|
3619
3841
|
}
|
|
3620
3842
|
if (!isContainer && s.containers !== undefined) {
|
|
3621
3843
|
ctx.addIssue({
|
|
3622
|
-
code:
|
|
3844
|
+
code: z5.ZodIssueCode.custom,
|
|
3623
3845
|
path: ["containers"],
|
|
3624
3846
|
message: `containers[] is only allowed when appType is 'container' (current appType: '${s.appType}')`
|
|
3625
3847
|
});
|
|
3626
3848
|
}
|
|
3627
3849
|
if (isContainer && s.build !== undefined) {
|
|
3628
3850
|
ctx.addIssue({
|
|
3629
|
-
code:
|
|
3851
|
+
code: z5.ZodIssueCode.custom,
|
|
3630
3852
|
path: ["build"],
|
|
3631
3853
|
message: "build is not allowed when appType is 'container' (container build lives in the Dockerfile)"
|
|
3632
3854
|
});
|
|
3633
3855
|
}
|
|
3634
3856
|
if (!isContainer && s.fronted_by_concierge === true) {
|
|
3635
3857
|
ctx.addIssue({
|
|
3636
|
-
code:
|
|
3858
|
+
code: z5.ZodIssueCode.custom,
|
|
3637
3859
|
path: ["fronted_by_concierge"],
|
|
3638
3860
|
message: `fronted_by_concierge is only allowed when appType is 'container' (current appType: '${s.appType}')`
|
|
3639
3861
|
});
|
|
3640
3862
|
}
|
|
3641
3863
|
});
|
|
3642
|
-
var nonEmpty =
|
|
3643
|
-
var StatusSchema =
|
|
3644
|
-
schemaVersion:
|
|
3864
|
+
var nonEmpty = z5.string().min(1);
|
|
3865
|
+
var StatusSchema = z5.object({
|
|
3866
|
+
schemaVersion: z5.literal(2),
|
|
3645
3867
|
manifest_spec_sha: nonEmpty,
|
|
3646
|
-
cloudflare:
|
|
3647
|
-
access:
|
|
3868
|
+
cloudflare: z5.object({
|
|
3869
|
+
access: z5.object({
|
|
3648
3870
|
app_id: nonEmpty,
|
|
3649
3871
|
app_aud: nonEmpty,
|
|
3650
3872
|
team_domain: nonEmpty,
|
|
3651
3873
|
policy_id: nonEmpty
|
|
3652
3874
|
}).strict(),
|
|
3653
|
-
pages:
|
|
3875
|
+
pages: z5.object({
|
|
3654
3876
|
project_name: nonEmpty,
|
|
3655
3877
|
subdomain: nonEmpty,
|
|
3656
3878
|
latest_deployment_id: nonEmpty
|
|
3657
3879
|
}).strict().optional(),
|
|
3658
|
-
worker:
|
|
3880
|
+
worker: z5.object({
|
|
3659
3881
|
dev_url: nonEmpty,
|
|
3660
3882
|
script_name: nonEmpty
|
|
3661
3883
|
}).strict().optional()
|
|
3662
3884
|
}).strict(),
|
|
3663
|
-
dns:
|
|
3664
|
-
terraform:
|
|
3885
|
+
dns: z5.object({ custom_hostname: nonEmpty, cname_target: nonEmpty }).strict().optional(),
|
|
3886
|
+
terraform: z5.object({
|
|
3665
3887
|
workspace_state_key: nonEmpty,
|
|
3666
3888
|
last_applied_at: nonEmpty,
|
|
3667
3889
|
last_applied_sha: nonEmpty
|
|
3668
3890
|
}).strict(),
|
|
3669
|
-
registry:
|
|
3891
|
+
registry: z5.object({ record_present: z5.boolean(), lifecycle: nonEmpty }).strict(),
|
|
3670
3892
|
generated_at: nonEmpty
|
|
3671
3893
|
}).strict().superRefine((s, ctx) => {
|
|
3672
3894
|
const hasPages = s.cloudflare.pages !== undefined;
|
|
3673
3895
|
const hasWorker = s.cloudflare.worker !== undefined;
|
|
3674
3896
|
if (hasPages === hasWorker) {
|
|
3675
3897
|
ctx.addIssue({
|
|
3676
|
-
code:
|
|
3898
|
+
code: z5.ZodIssueCode.custom,
|
|
3677
3899
|
path: ["cloudflare"],
|
|
3678
3900
|
message: "status.cloudflare must carry exactly one of `pages` (pages apps) or `worker` (container apps)"
|
|
3679
3901
|
});
|
|
3680
3902
|
}
|
|
3681
3903
|
if (hasPages && s.dns === undefined) {
|
|
3682
3904
|
ctx.addIssue({
|
|
3683
|
-
code:
|
|
3905
|
+
code: z5.ZodIssueCode.custom,
|
|
3684
3906
|
path: ["dns"],
|
|
3685
3907
|
message: "status.dns is required for a pages-shape status (cloudflare.pages present)"
|
|
3686
3908
|
});
|
|
3687
3909
|
}
|
|
3688
3910
|
if (hasWorker && s.dns !== undefined) {
|
|
3689
3911
|
ctx.addIssue({
|
|
3690
|
-
code:
|
|
3912
|
+
code: z5.ZodIssueCode.custom,
|
|
3691
3913
|
path: ["dns"],
|
|
3692
3914
|
message: "status.dns must be absent for a workers_dev_only container status (no custom hostname)"
|
|
3693
3915
|
});
|
|
3694
3916
|
}
|
|
3695
3917
|
});
|
|
3696
|
-
var ManifestV2Schema =
|
|
3697
|
-
apiVersion:
|
|
3698
|
-
kind:
|
|
3699
|
-
metadata:
|
|
3700
|
-
slug:
|
|
3701
|
-
schemaVersion:
|
|
3918
|
+
var ManifestV2Schema = z5.object({
|
|
3919
|
+
apiVersion: z5.literal("launchpad.m-kopa.us/v2"),
|
|
3920
|
+
kind: z5.literal("App"),
|
|
3921
|
+
metadata: z5.object({
|
|
3922
|
+
slug: z5.string().min(2).max(63).regex(SLUG_REGEX, "must be lowercase letters, digits, and hyphens; start/end alphanumeric"),
|
|
3923
|
+
schemaVersion: z5.literal(2)
|
|
3702
3924
|
}).strict(),
|
|
3703
3925
|
spec: SpecSchema,
|
|
3704
3926
|
status: StatusSchema.optional()
|
|
@@ -3707,7 +3929,7 @@ var ManifestV2Schema = z4.object({
|
|
|
3707
3929
|
(m.spec.targets ?? []).forEach((t, i) => {
|
|
3708
3930
|
if (t.kind === "worker" && t.script !== undefined && !t.script.startsWith(prefix)) {
|
|
3709
3931
|
ctx.addIssue({
|
|
3710
|
-
code:
|
|
3932
|
+
code: z5.ZodIssueCode.custom,
|
|
3711
3933
|
path: ["spec", "targets", i, "script"],
|
|
3712
3934
|
message: `worker target script '${t.script}' must start with '${prefix}' (the app slug plus a dash)`
|
|
3713
3935
|
});
|
|
@@ -4885,8 +5107,9 @@ function assertBroadGroupsWellFormed(list = BROAD_GROUPS) {
|
|
|
4885
5107
|
}
|
|
4886
5108
|
assertBroadGroupsWellFormed();
|
|
4887
5109
|
var BROAD_UUIDS = new Set(BROAD_GROUPS.map((g) => canonicalUuid(g.uuid)).filter((u) => u !== null));
|
|
5110
|
+
var BROAD_NAMES = new Set(BROAD_GROUPS.map((g) => g.name.trim().toLowerCase()));
|
|
4888
5111
|
// ../launchpad-engine/dist/fleet-manifest.js
|
|
4889
|
-
import { z as
|
|
5112
|
+
import { z as z6 } from "zod";
|
|
4890
5113
|
var UUID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
4891
5114
|
var TF_RESIDENCIES = ["per-app-workspace", "main-tf"];
|
|
4892
5115
|
var APP_SHAPES = [
|
|
@@ -4914,22 +5137,22 @@ var FLEET_TIERS = [
|
|
|
4914
5137
|
"out-of-scope"
|
|
4915
5138
|
];
|
|
4916
5139
|
var DEVICE_POSTURE = ["gateway-eligible", "retained-access"];
|
|
4917
|
-
var GroupId =
|
|
4918
|
-
var FleetAppSchema =
|
|
4919
|
-
slug:
|
|
4920
|
-
residency:
|
|
4921
|
-
shape:
|
|
4922
|
-
declaredAuth:
|
|
4923
|
-
actualAuth:
|
|
4924
|
-
groups:
|
|
4925
|
-
tier:
|
|
4926
|
-
devicePosture:
|
|
4927
|
-
devicePostureReason:
|
|
4928
|
-
notes:
|
|
5140
|
+
var GroupId = z6.string().regex(UUID_RE, "Entra group ids are emitted as canonical UUIDs in the JWT groups claim — display names will not match policies.");
|
|
5141
|
+
var FleetAppSchema = z6.object({
|
|
5142
|
+
slug: z6.string().regex(SLUG_REGEX),
|
|
5143
|
+
residency: z6.enum(TF_RESIDENCIES),
|
|
5144
|
+
shape: z6.enum(APP_SHAPES),
|
|
5145
|
+
declaredAuth: z6.enum(DECLARED_AUTH),
|
|
5146
|
+
actualAuth: z6.enum(ACTUAL_AUTH),
|
|
5147
|
+
groups: z6.array(GroupId).default([]),
|
|
5148
|
+
tier: z6.enum(FLEET_TIERS),
|
|
5149
|
+
devicePosture: z6.enum(DEVICE_POSTURE),
|
|
5150
|
+
devicePostureReason: z6.string().trim().min(1, "devicePosture is only valid with a non-empty reason — the two-tier determination must be a surveyed output, not a default (AC-T0-3)."),
|
|
5151
|
+
notes: z6.string().optional()
|
|
4929
5152
|
}).strict();
|
|
4930
|
-
var FleetManifestSchema =
|
|
4931
|
-
schemaVersion:
|
|
4932
|
-
apps:
|
|
5153
|
+
var FleetManifestSchema = z6.object({
|
|
5154
|
+
schemaVersion: z6.literal(1),
|
|
5155
|
+
apps: z6.array(FleetAppSchema).min(1)
|
|
4933
5156
|
}).strict().superRefine((m, ctx) => {
|
|
4934
5157
|
const seen = new Set;
|
|
4935
5158
|
for (const app of m.apps) {
|
|
@@ -4951,23 +5174,23 @@ var FleetManifestSchema = z5.object({
|
|
|
4951
5174
|
}
|
|
4952
5175
|
});
|
|
4953
5176
|
// ../launchpad-engine/dist/fleet-secret-sets.js
|
|
4954
|
-
import { z as
|
|
5177
|
+
import { z as z7 } from "zod";
|
|
4955
5178
|
var SET_NAME_REGEX = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
|
|
4956
|
-
var Slug =
|
|
4957
|
-
var SecretName =
|
|
4958
|
-
var SecretSetExcludeSchema =
|
|
5179
|
+
var Slug = z7.string().regex(SLUG_REGEX, "member must be a lowercase-kebab app slug");
|
|
5180
|
+
var SecretName = z7.string().regex(ENV_NAME_REGEX, "secret name must be UPPER_SNAKE_CASE");
|
|
5181
|
+
var SecretSetExcludeSchema = z7.object({
|
|
4959
5182
|
member: Slug,
|
|
4960
5183
|
secret: SecretName
|
|
4961
5184
|
}).strict();
|
|
4962
|
-
var SecretSetSchema =
|
|
4963
|
-
name:
|
|
4964
|
-
secrets:
|
|
4965
|
-
members:
|
|
4966
|
-
exclude:
|
|
5185
|
+
var SecretSetSchema = z7.object({
|
|
5186
|
+
name: z7.string().min(1).max(64).regex(SET_NAME_REGEX, "set name must be lowercase-kebab"),
|
|
5187
|
+
secrets: z7.array(SecretName).min(1),
|
|
5188
|
+
members: z7.array(Slug).min(1),
|
|
5189
|
+
exclude: z7.array(SecretSetExcludeSchema).optional()
|
|
4967
5190
|
}).strict();
|
|
4968
|
-
var FleetSecretSetsSchema =
|
|
4969
|
-
schemaVersion:
|
|
4970
|
-
secretSets:
|
|
5191
|
+
var FleetSecretSetsSchema = z7.object({
|
|
5192
|
+
schemaVersion: z7.literal(1),
|
|
5193
|
+
secretSets: z7.array(SecretSetSchema).min(1)
|
|
4971
5194
|
}).strict().superRefine((m, ctx) => {
|
|
4972
5195
|
const seenSets = new Set;
|
|
4973
5196
|
for (let i = 0;i < m.secretSets.length; i++) {
|
|
@@ -5100,14 +5323,16 @@ function dispatchManifest(manifest, wrangler = {}) {
|
|
|
5100
5323
|
audience: manifest.access.audience,
|
|
5101
5324
|
private_owner: manifest.access.private_owner,
|
|
5102
5325
|
allowed_entra_groups: [...allowedEntraGroups(manifest.access)],
|
|
5103
|
-
identity_types: manifest.access.identity_types
|
|
5326
|
+
identity_types: manifest.access.identity_types,
|
|
5327
|
+
broad_audience_ack: manifest.access.broad_audience_ack
|
|
5104
5328
|
},
|
|
5105
5329
|
build: manifest.build,
|
|
5106
5330
|
app: manifest.app,
|
|
5107
5331
|
verify: manifest.verify,
|
|
5108
5332
|
sensitive: manifest.sensitive,
|
|
5109
5333
|
catalogue: manifest.catalogue,
|
|
5110
|
-
integrations: manifest.integrations
|
|
5334
|
+
integrations: manifest.integrations,
|
|
5335
|
+
boundary: manifest.boundary
|
|
5111
5336
|
};
|
|
5112
5337
|
const candidate = {
|
|
5113
5338
|
apiVersion: "launchpad.m-kopa.us/v2",
|
|
@@ -5205,6 +5430,293 @@ function pagesTargetD1(manifest) {
|
|
|
5205
5430
|
return;
|
|
5206
5431
|
return target.d1_binding;
|
|
5207
5432
|
}
|
|
5433
|
+
// ../launchpad-engine/dist/boundary-proposal.js
|
|
5434
|
+
var REVIEW_TEST_CODES = Object.fromEntries(BOUNDARY_TESTS.map((t, i) => [`T${i + 1}`, t]));
|
|
5435
|
+
// ../launchpad-engine/dist/app-server-code.js
|
|
5436
|
+
var MAX_FILE_CHARS = 512000;
|
|
5437
|
+
var SERVER_PATH_RX = new RegExp("^(functions|server|worker|workers|backend|api|app/api|pages/api|netlify/functions|" + "src/(worker|server|api|functions)|apps/[^/]+/(src/)?(api|worker|server)|react-api/(src|functions|worker))/" + "|^(static/|public/|dist/)?_worker\\.js$|^(worker|server|main|app)\\.(js|ts|mjs|py)$");
|
|
5438
|
+
var CODE_EXT_RX = /\.(?:m?js|cjs|jsx|tsx?|mts|py)$/;
|
|
5439
|
+
var TEST_PATH_RX = /(?:^|\/)(?:tests?|__tests__|__mocks__|fixtures?|node_modules|dist|coverage)\/|\.(?:test|spec)\.[a-z]+$/;
|
|
5440
|
+
var CLIENT_RECV = new Set([
|
|
5441
|
+
"axios",
|
|
5442
|
+
"http",
|
|
5443
|
+
"https",
|
|
5444
|
+
"got",
|
|
5445
|
+
"ky",
|
|
5446
|
+
"superagent",
|
|
5447
|
+
"request",
|
|
5448
|
+
"requests",
|
|
5449
|
+
"httpx",
|
|
5450
|
+
"session",
|
|
5451
|
+
"client",
|
|
5452
|
+
"$",
|
|
5453
|
+
"kv",
|
|
5454
|
+
"db",
|
|
5455
|
+
"cache",
|
|
5456
|
+
"cy",
|
|
5457
|
+
"page",
|
|
5458
|
+
"agent",
|
|
5459
|
+
"fetcher",
|
|
5460
|
+
"jquery",
|
|
5461
|
+
"ajax",
|
|
5462
|
+
"supabase",
|
|
5463
|
+
"stub",
|
|
5464
|
+
"mock"
|
|
5465
|
+
]);
|
|
5466
|
+
var JS_ROUTE_RX = /\b([A-Za-z_$][\w$]*)\s*\.\s*(post|put|patch|delete)\s*\(\s*(['"`])(\/[^'"`]*|\*)\3/g;
|
|
5467
|
+
var PAGES_EXPORT_RX = /export\s+(?:async\s+)?(?:function|const)\s+onRequest(Post|Put|Patch|Delete)\b/g;
|
|
5468
|
+
var METHOD_BRANCH_RX = /\bmethod\s*(?:===|==)\s*['"](POST|PUT|PATCH|DELETE)['"]|\bcase\s+['"](POST|PUT|PATCH|DELETE)['"]\s*:/g;
|
|
5469
|
+
var PY_ROUTE_RX = /@\s*\w+\.(post|put|patch|delete)\s*\(\s*['"](\/[^'"]*)|methods\s*=\s*\[[^\]]{0,500}['"](POST|PUT|PATCH|DELETE)['"]/gi;
|
|
5470
|
+
var REL_IMPORT_RX = /(?:from\s+|import\s*\(\s*|require\s*\(\s*)['"](\.{1,2}\/[^'"]+)['"]/g;
|
|
5471
|
+
var AUTH_REF_RX = new RegExp("platform-auth|@m-kopa/platform|assertion|requireStaff|requireAuth|requireUser|requireRole|" + "requireCaller|requireIdentity|requireSession|requireAdmin|authMiddleware|jwtVerify|jwks|\\bverify[A-Za-z]*\\s*\\(|x-launchpad", "i");
|
|
5472
|
+
var JS_LINE_COMMENT_RX = /^[ \t]*(?:\/\/|\/\*|\*).*$/gm;
|
|
5473
|
+
var PY_LINE_COMMENT_RX = /^[ \t]*#.*$/gm;
|
|
5474
|
+
function stripLineComments(text, rel) {
|
|
5475
|
+
return text.replace(rel.endsWith(".py") ? PY_LINE_COMMENT_RX : JS_LINE_COMMENT_RX, "");
|
|
5476
|
+
}
|
|
5477
|
+
var VENDORED_VERIFIER_RX = /(?:^|\/)platform-auth\.(?:m?js|ts)$/;
|
|
5478
|
+
function isVendoredVerifierPath(rel) {
|
|
5479
|
+
return VENDORED_VERIFIER_RX.test(rel);
|
|
5480
|
+
}
|
|
5481
|
+
function relativeToRoot(path7, rootDir) {
|
|
5482
|
+
const root = normalisePath(rootDir ?? "");
|
|
5483
|
+
const p = normalisePath(path7);
|
|
5484
|
+
if (root === "" || root === ".")
|
|
5485
|
+
return p;
|
|
5486
|
+
return p.startsWith(`${root}/`) ? p.slice(root.length + 1) : null;
|
|
5487
|
+
}
|
|
5488
|
+
function normalisePath(path7) {
|
|
5489
|
+
const out = [];
|
|
5490
|
+
for (const part of path7.replace(/\\/g, "/").split("/")) {
|
|
5491
|
+
if (part === "" || part === ".")
|
|
5492
|
+
continue;
|
|
5493
|
+
if (part === "..")
|
|
5494
|
+
out.pop();
|
|
5495
|
+
else
|
|
5496
|
+
out.push(part);
|
|
5497
|
+
}
|
|
5498
|
+
return out.join("/");
|
|
5499
|
+
}
|
|
5500
|
+
function dirOf(path7) {
|
|
5501
|
+
const i = path7.lastIndexOf("/");
|
|
5502
|
+
return i < 0 ? "" : path7.slice(0, i);
|
|
5503
|
+
}
|
|
5504
|
+
function baseOf(path7) {
|
|
5505
|
+
return path7.slice(path7.lastIndexOf("/") + 1);
|
|
5506
|
+
}
|
|
5507
|
+
function isServerCodePath(rel) {
|
|
5508
|
+
return SERVER_PATH_RX.test(rel) && CODE_EXT_RX.test(rel) && !TEST_PATH_RX.test(rel);
|
|
5509
|
+
}
|
|
5510
|
+
function findWriteRoutes(text, rel) {
|
|
5511
|
+
const out = [];
|
|
5512
|
+
if (rel.endsWith(".py")) {
|
|
5513
|
+
for (const m of text.matchAll(PY_ROUTE_RX)) {
|
|
5514
|
+
out.push({ at: m.index, method: (m[1] ?? m[3] ?? "POST").toUpperCase() });
|
|
5515
|
+
}
|
|
5516
|
+
return out.map((r) => r.method);
|
|
5517
|
+
}
|
|
5518
|
+
for (const m of text.matchAll(JS_ROUTE_RX)) {
|
|
5519
|
+
if (CLIENT_RECV.has((m[1] ?? "").toLowerCase()))
|
|
5520
|
+
continue;
|
|
5521
|
+
out.push({ at: m.index, method: (m[2] ?? "post").toUpperCase() });
|
|
5522
|
+
}
|
|
5523
|
+
for (const m of text.matchAll(PAGES_EXPORT_RX)) {
|
|
5524
|
+
out.push({ at: m.index, method: (m[1] ?? "Post").toUpperCase() });
|
|
5525
|
+
}
|
|
5526
|
+
if (rel.startsWith("functions/") || rel.startsWith("pages/api/") || /(?:^|\/)_?worker\.(?:js|ts)$/.test(rel)) {
|
|
5527
|
+
for (const m of text.matchAll(METHOD_BRANCH_RX)) {
|
|
5528
|
+
out.push({ at: m.index, method: m[1] ?? m[2] ?? "POST" });
|
|
5529
|
+
}
|
|
5530
|
+
}
|
|
5531
|
+
return out.sort((a, b) => a.at - b.at).map((r) => r.method);
|
|
5532
|
+
}
|
|
5533
|
+
function resolveImport(rel, spec, known) {
|
|
5534
|
+
const base = normalisePath(`${dirOf(rel)}/${spec}`);
|
|
5535
|
+
const stem = base.replace(/\.(?:m?js|jsx|tsx?)$/, "");
|
|
5536
|
+
for (const b of [base, stem]) {
|
|
5537
|
+
for (const cand of [b, `${b}.ts`, `${b}.js`, `${b}.mjs`, `${b}.tsx`, `${b}.jsx`, `${b}.py`, `${b}/index.ts`, `${b}/index.js`]) {
|
|
5538
|
+
if (known.has(cand))
|
|
5539
|
+
return cand;
|
|
5540
|
+
}
|
|
5541
|
+
}
|
|
5542
|
+
return null;
|
|
5543
|
+
}
|
|
5544
|
+
function relativeImports(text) {
|
|
5545
|
+
return [...text.matchAll(REL_IMPORT_RX)].map((m) => m[1] ?? "").filter((s) => s !== "");
|
|
5546
|
+
}
|
|
5547
|
+
function collectServerFiles(files, options = {}) {
|
|
5548
|
+
const raw = new Map;
|
|
5549
|
+
for (const [path7, content] of Object.entries(files)) {
|
|
5550
|
+
const rel = relativeToRoot(path7, options.rootDir);
|
|
5551
|
+
if (rel === null || !isServerCodePath(rel) || content.length > MAX_FILE_CHARS)
|
|
5552
|
+
continue;
|
|
5553
|
+
raw.set(rel, content);
|
|
5554
|
+
}
|
|
5555
|
+
const known = new Set(raw.keys());
|
|
5556
|
+
const out = new Map;
|
|
5557
|
+
for (const [rel, content] of raw) {
|
|
5558
|
+
const imports = relativeImports(content).map((s) => resolveImport(rel, s, known)).filter((x) => x !== null);
|
|
5559
|
+
const code = stripLineComments(content, rel);
|
|
5560
|
+
out.set(rel, {
|
|
5561
|
+
path: rel,
|
|
5562
|
+
content,
|
|
5563
|
+
code,
|
|
5564
|
+
writeRoutes: findWriteRoutes(content, rel),
|
|
5565
|
+
authRef: AUTH_REF_RX.test(code),
|
|
5566
|
+
imports
|
|
5567
|
+
});
|
|
5568
|
+
}
|
|
5569
|
+
return out;
|
|
5570
|
+
}
|
|
5571
|
+
function reach(start, graph, depth) {
|
|
5572
|
+
const seen = new Set([start]);
|
|
5573
|
+
let frontier = new Set([start]);
|
|
5574
|
+
for (let i = 0;i < depth; i++) {
|
|
5575
|
+
const next = new Set;
|
|
5576
|
+
for (const x of frontier) {
|
|
5577
|
+
for (const y of graph.get(x) ?? []) {
|
|
5578
|
+
if (!seen.has(y)) {
|
|
5579
|
+
seen.add(y);
|
|
5580
|
+
next.add(y);
|
|
5581
|
+
}
|
|
5582
|
+
}
|
|
5583
|
+
}
|
|
5584
|
+
frontier = next;
|
|
5585
|
+
}
|
|
5586
|
+
seen.delete(start);
|
|
5587
|
+
return seen;
|
|
5588
|
+
}
|
|
5589
|
+
function importGraphs(files) {
|
|
5590
|
+
const imports = new Map;
|
|
5591
|
+
const importedBy = new Map;
|
|
5592
|
+
for (const [rel, f] of files) {
|
|
5593
|
+
imports.set(rel, f.imports);
|
|
5594
|
+
for (const x of f.imports) {
|
|
5595
|
+
const list = importedBy.get(x) ?? [];
|
|
5596
|
+
list.push(rel);
|
|
5597
|
+
importedBy.set(x, list);
|
|
5598
|
+
}
|
|
5599
|
+
}
|
|
5600
|
+
return { imports, importedBy };
|
|
5601
|
+
}
|
|
5602
|
+
function coveredByMiddleware(rel, files, pred) {
|
|
5603
|
+
let d = dirOf(rel);
|
|
5604
|
+
for (;; ) {
|
|
5605
|
+
for (const f of files.values()) {
|
|
5606
|
+
if (dirOf(f.path) === d && baseOf(f.path).startsWith("_middleware") && pred(f))
|
|
5607
|
+
return true;
|
|
5608
|
+
}
|
|
5609
|
+
if (d === "")
|
|
5610
|
+
return false;
|
|
5611
|
+
d = dirOf(d);
|
|
5612
|
+
}
|
|
5613
|
+
}
|
|
5614
|
+
|
|
5615
|
+
// ../launchpad-engine/dist/route-auth-lint.js
|
|
5616
|
+
function lintRouteAuth(files, options = {}) {
|
|
5617
|
+
const server = collectServerFiles(files, options);
|
|
5618
|
+
const { imports, importedBy } = importGraphs(server);
|
|
5619
|
+
const appHasAuthRef = [...server.values()].some((f) => f.authRef);
|
|
5620
|
+
const hasWrites = (p) => (server.get(p)?.writeRoutes.length ?? 0) > 0;
|
|
5621
|
+
const guardsWrites = (f) => {
|
|
5622
|
+
if (!f.authRef || isVendoredVerifierPath(f.path))
|
|
5623
|
+
return false;
|
|
5624
|
+
if (f.writeRoutes.length > 0)
|
|
5625
|
+
return true;
|
|
5626
|
+
if (f.path.slice(f.path.lastIndexOf("/") + 1).startsWith("_middleware"))
|
|
5627
|
+
return true;
|
|
5628
|
+
return [...reach(f.path, importedBy, 3)].some(hasWrites);
|
|
5629
|
+
};
|
|
5630
|
+
const appGuardsWrites = [...server.values()].some(guardsWrites);
|
|
5631
|
+
const authed = (p) => server.get(p)?.authRef === true;
|
|
5632
|
+
const findings = [];
|
|
5633
|
+
let writeRoutes = 0;
|
|
5634
|
+
for (const f of [...server.values()].sort((a, b) => a.path.localeCompare(b.path))) {
|
|
5635
|
+
if (f.writeRoutes.length === 0)
|
|
5636
|
+
continue;
|
|
5637
|
+
writeRoutes += f.writeRoutes.length;
|
|
5638
|
+
const covered = f.authRef || [...reach(f.path, imports, 3)].some(authed) || [...reach(f.path, importedBy, 2)].some(authed) || coveredByMiddleware(f.path, server, (m) => m.authRef);
|
|
5639
|
+
if (covered)
|
|
5640
|
+
continue;
|
|
5641
|
+
findings.push({
|
|
5642
|
+
path: f.path,
|
|
5643
|
+
rule: "route-without-auth",
|
|
5644
|
+
severity: appGuardsWrites ? "medium" : "high",
|
|
5645
|
+
methods: [...new Set(f.writeRoutes)].sort(),
|
|
5646
|
+
routes: f.writeRoutes.length
|
|
5647
|
+
});
|
|
5648
|
+
}
|
|
5649
|
+
return { serverFiles: server.size, writeRoutes, appHasAuthRef, appGuardsWrites, findings };
|
|
5650
|
+
}
|
|
5651
|
+
// ../launchpad-engine/dist/assertion-verify-lint.js
|
|
5652
|
+
var APP_SESSION_MAX_SECONDS = 3600;
|
|
5653
|
+
var ASSERTION_READ_RX = /x-launchpad-user-assertion|cf-access-jwt-assertion|GATEWAY_ASSERTION_HEADER_NAME|CF_ACCESS_HEADER_NAME|parseGatewayAssertionFromHeaders|parseAccessJwtFromHeaders/i;
|
|
5654
|
+
var PLATFORM_AUTH_IMPORT_RX = /['"](?:@m-kopa\/platform-auth(?:\/hono)?|\.{1,2}\/(?:[^'"\n]*\/)?platform-auth(?:\.m?js|\.ts)?)['"]/;
|
|
5655
|
+
var PLATFORM_AUTH_CALL_RX = /\b(?:verifyAccessJwt|verifyJwt|verifyIntegrationAssertion|createPlatformAuthMiddleware)\s*\(/;
|
|
5656
|
+
var DECODE_RX = /\batob\s*\(|Buffer\.from\s*\([^)]{0,200}['"]base64(?:url)?['"]|\bdecodeJwt\s*\(|\bjwt\.decode\s*\(|\bjwtDecode\s*\(|\.split\s*\(\s*['"]\.['"]\s*\)/;
|
|
5657
|
+
var OTHER_VERIFY_RX = /\bjwtVerify\s*\(|createRemoteJWKSet\s*\(|subtle\.verify\s*\(/;
|
|
5658
|
+
var COOKIE_RX = /set-cookie|setCookie|\bcookie\b/i;
|
|
5659
|
+
var MAX_AGE_RX = /(?:max-age|maxAge)\s*[=:]\s*(\d{1,9})\b/gi;
|
|
5660
|
+
function usesPlatformAuth(f) {
|
|
5661
|
+
return PLATFORM_AUTH_IMPORT_RX.test(f.code) && PLATFORM_AUTH_CALL_RX.test(f.code);
|
|
5662
|
+
}
|
|
5663
|
+
function maxCookieAge(f) {
|
|
5664
|
+
if (!COOKIE_RX.test(f.code))
|
|
5665
|
+
return null;
|
|
5666
|
+
let max = null;
|
|
5667
|
+
for (const m of f.code.matchAll(MAX_AGE_RX)) {
|
|
5668
|
+
const n = Number(m[1]);
|
|
5669
|
+
if (max === null || n > max)
|
|
5670
|
+
max = n;
|
|
5671
|
+
}
|
|
5672
|
+
return max;
|
|
5673
|
+
}
|
|
5674
|
+
function lintAssertionVerification(files, options = {}) {
|
|
5675
|
+
const server = collectServerFiles(files, options);
|
|
5676
|
+
if (server.size === 0) {
|
|
5677
|
+
return { status: "no-server-code", readers: 0, usesPlatformAuth: false, findings: [] };
|
|
5678
|
+
}
|
|
5679
|
+
const { imports } = importGraphs(server);
|
|
5680
|
+
const inReach = (f, pred) => pred(f) || [...reach(f.path, imports, 3)].some((p) => {
|
|
5681
|
+
const x = server.get(p);
|
|
5682
|
+
return x !== undefined && pred(x);
|
|
5683
|
+
});
|
|
5684
|
+
const findings = [];
|
|
5685
|
+
let readers = 0;
|
|
5686
|
+
let uncovered = 0;
|
|
5687
|
+
const sorted = [...server.values()].sort((a, b) => a.path.localeCompare(b.path));
|
|
5688
|
+
for (const f of sorted) {
|
|
5689
|
+
if (isVendoredVerifierPath(f.path))
|
|
5690
|
+
continue;
|
|
5691
|
+
if (usesPlatformAuth(f)) {
|
|
5692
|
+
readers++;
|
|
5693
|
+
} else if (ASSERTION_READ_RX.test(f.code)) {
|
|
5694
|
+
readers++;
|
|
5695
|
+
if (!inReach(f, usesPlatformAuth)) {
|
|
5696
|
+
uncovered++;
|
|
5697
|
+
const otherVerifier = inReach(f, (x) => OTHER_VERIFY_RX.test(x.code));
|
|
5698
|
+
if (otherVerifier) {
|
|
5699
|
+
findings.push({ path: f.path, rule: "assertion-verified-without-platform-auth", severity: "low" });
|
|
5700
|
+
} else if (inReach(f, (x) => !isVendoredVerifierPath(x.path) && DECODE_RX.test(x.code))) {
|
|
5701
|
+
findings.push({ path: f.path, rule: "assertion-decoded-without-verify", severity: "high" });
|
|
5702
|
+
} else {
|
|
5703
|
+
findings.push({ path: f.path, rule: "assertion-read-without-platform-auth", severity: "medium" });
|
|
5704
|
+
}
|
|
5705
|
+
}
|
|
5706
|
+
}
|
|
5707
|
+
const age = maxCookieAge(f);
|
|
5708
|
+
if (age !== null && age > APP_SESSION_MAX_SECONDS) {
|
|
5709
|
+
findings.push({ path: f.path, rule: "app-session-over-1h", severity: "low", maxAgeSeconds: age });
|
|
5710
|
+
}
|
|
5711
|
+
}
|
|
5712
|
+
const status = readers === 0 ? "no-assertion-use" : uncovered === 0 ? "verified" : "not-verified";
|
|
5713
|
+
return {
|
|
5714
|
+
status,
|
|
5715
|
+
readers,
|
|
5716
|
+
usesPlatformAuth: sorted.some(usesPlatformAuth),
|
|
5717
|
+
findings
|
|
5718
|
+
};
|
|
5719
|
+
}
|
|
5208
5720
|
// src/bundle/boundary.ts
|
|
5209
5721
|
var MAX_CONTENT_PROBE_BYTES = 1024 * 1024;
|
|
5210
5722
|
function applyBoundaryToFiles(args) {
|
|
@@ -5371,7 +5883,7 @@ import { readFileSync as readFileSync10, existsSync as existsSync4 } from "node:
|
|
|
5371
5883
|
import { join as join9 } from "node:path";
|
|
5372
5884
|
|
|
5373
5885
|
// src/deploy/deployment-status.ts
|
|
5374
|
-
import { z as
|
|
5886
|
+
import { z as z9 } from "zod";
|
|
5375
5887
|
|
|
5376
5888
|
// src/deploy/redact-diagnostic.ts
|
|
5377
5889
|
var MAX_DIAGNOSTIC_LEN = 600;
|
|
@@ -5389,19 +5901,19 @@ function redactDiagnostic(text, maxLen = MAX_DIAGNOSTIC_LEN) {
|
|
|
5389
5901
|
}
|
|
5390
5902
|
|
|
5391
5903
|
// src/notices.ts
|
|
5392
|
-
import { z as
|
|
5904
|
+
import { z as z8 } from "zod";
|
|
5393
5905
|
var NOTICE_COMMAND_ALLOWLIST = new Set([
|
|
5394
5906
|
"launchpad migrate --origin dispatch --dry-run",
|
|
5395
5907
|
"launchpad migrate --status",
|
|
5396
5908
|
"launchpad migrate --finalize"
|
|
5397
5909
|
]);
|
|
5398
5910
|
var MAX_TEXT = 300;
|
|
5399
|
-
var NoticeSchema =
|
|
5400
|
-
id:
|
|
5401
|
-
schema:
|
|
5402
|
-
level:
|
|
5403
|
-
text:
|
|
5404
|
-
command:
|
|
5911
|
+
var NoticeSchema = z8.object({
|
|
5912
|
+
id: z8.string().regex(/^[a-z][a-z0-9_]{0,63}$/),
|
|
5913
|
+
schema: z8.literal(1),
|
|
5914
|
+
level: z8.enum(["info", "warning"]),
|
|
5915
|
+
text: z8.string().transform(clean).pipe(z8.string().min(1)),
|
|
5916
|
+
command: z8.string().optional().catch(undefined)
|
|
5405
5917
|
});
|
|
5406
5918
|
function parseNotices(raw) {
|
|
5407
5919
|
if (!Array.isArray(raw))
|
|
@@ -5509,16 +6021,16 @@ function projectV2(value) {
|
|
|
5509
6021
|
};
|
|
5510
6022
|
return { v2 };
|
|
5511
6023
|
}
|
|
5512
|
-
var Sha40 =
|
|
5513
|
-
var VerifiedCommitSchema =
|
|
6024
|
+
var Sha40 = z9.string().regex(/^[0-9a-f]{40}$/);
|
|
6025
|
+
var VerifiedCommitSchema = z9.object({
|
|
5514
6026
|
commitSha: Sha40,
|
|
5515
|
-
runId:
|
|
5516
|
-
artifactSha256:
|
|
5517
|
-
verifiedAt:
|
|
5518
|
-
runUrl:
|
|
6027
|
+
runId: z9.number().int().positive(),
|
|
6028
|
+
artifactSha256: z9.string().regex(/^[0-9a-f]{64}$/),
|
|
6029
|
+
verifiedAt: z9.string().transform((value) => redactDiagnostic(value)),
|
|
6030
|
+
runUrl: z9.unknown().optional()
|
|
5519
6031
|
});
|
|
5520
|
-
var ScriptBindingSchema =
|
|
5521
|
-
state:
|
|
6032
|
+
var ScriptBindingSchema = z9.object({
|
|
6033
|
+
state: z9.enum(["match", "mismatch", "unbound", "unreadable"]),
|
|
5522
6034
|
commitSha: Sha40.optional().catch(undefined)
|
|
5523
6035
|
});
|
|
5524
6036
|
function projectVerifiedCommit(value) {
|
|
@@ -11078,10 +11590,10 @@ function saveMigration(file, original, converted) {
|
|
|
11078
11590
|
}
|
|
11079
11591
|
|
|
11080
11592
|
// src/integration-status.ts
|
|
11081
|
-
import { z as
|
|
11082
|
-
var EntrySchema =
|
|
11083
|
-
name:
|
|
11084
|
-
status:
|
|
11593
|
+
import { z as z10 } from "zod";
|
|
11594
|
+
var EntrySchema = z10.object({
|
|
11595
|
+
name: z10.string().regex(INTEGRATION_NAME_REGEX),
|
|
11596
|
+
status: z10.enum(["approved", "pending", "unavailable"])
|
|
11085
11597
|
});
|
|
11086
11598
|
function integrationStatusLines(raw) {
|
|
11087
11599
|
if (!Array.isArray(raw))
|
|
@@ -11783,6 +12295,25 @@ ${w}`, ""), message);
|
|
|
11783
12295
|
io.err(` - ${String(f.path)} [${String(f.rule)}]`);
|
|
11784
12296
|
}
|
|
11785
12297
|
}
|
|
12298
|
+
if (body.holds !== undefined && body.holds.length > 0) {
|
|
12299
|
+
io.err(" Boundary hold (paused for review, the live app keeps running):");
|
|
12300
|
+
for (const h of body.holds) {
|
|
12301
|
+
const where = [h.path, h.line === undefined ? undefined : `line ${h.line}`, h.host].filter((x) => x !== undefined).join(", ");
|
|
12302
|
+
io.err(` - ${h.flag}${where === "" ? "" : ` (${where})`}`);
|
|
12303
|
+
}
|
|
12304
|
+
}
|
|
12305
|
+
if (body.served_data_findings !== undefined && body.served_data_findings.length > 0) {
|
|
12306
|
+
io.err(" Record-level data in served files (paths and column names only):");
|
|
12307
|
+
for (const f of body.served_data_findings) {
|
|
12308
|
+
const cols = f.columns.length > 0 ? ` columns: ${f.columns.join(", ")}` : "";
|
|
12309
|
+
io.err(` - ${f.path} [${f.rule}]${cols}`);
|
|
12310
|
+
}
|
|
12311
|
+
}
|
|
12312
|
+
if (body.next_step !== undefined)
|
|
12313
|
+
io.err(` Next step: ${body.next_step}`);
|
|
12314
|
+
if (body.review_url !== undefined && body.review_url !== "") {
|
|
12315
|
+
io.err(` Review PR: ${body.review_url}`);
|
|
12316
|
+
}
|
|
11786
12317
|
if (errorCode === "bundle_policy_violation" || errorCode === "app_boundary_violation" || errorCode === "bad_build_command") {
|
|
11787
12318
|
io.err("");
|
|
11788
12319
|
io.err(" Nothing was committed or claimed by this attempt — fix the");
|
|
@@ -13114,9 +13645,9 @@ function describe22(e) {
|
|
|
13114
13645
|
|
|
13115
13646
|
// src/commands/init.ts
|
|
13116
13647
|
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
13117
|
-
import { existsSync as
|
|
13118
|
-
import { dirname as
|
|
13119
|
-
import { stringify as yamlStringify } from "yaml";
|
|
13648
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync5, readFileSync as readFileSync17, writeFileSync as writeFileSync5 } from "node:fs";
|
|
13649
|
+
import { dirname as dirname9, resolve as resolve12 } from "node:path";
|
|
13650
|
+
import { parse as yamlParse, stringify as yamlStringify } from "yaml";
|
|
13120
13651
|
|
|
13121
13652
|
// src/detect/index.ts
|
|
13122
13653
|
import { existsSync as existsSync11, readFileSync as readFileSync16, statSync } from "node:fs";
|
|
@@ -13273,50 +13804,421 @@ function detectDestinationDir(cwd, vite) {
|
|
|
13273
13804
|
return { kind: "ok", value: "dist" };
|
|
13274
13805
|
}
|
|
13275
13806
|
|
|
13276
|
-
// src/
|
|
13277
|
-
|
|
13278
|
-
|
|
13279
|
-
|
|
13280
|
-
|
|
13281
|
-
|
|
13282
|
-
|
|
13283
|
-
|
|
13284
|
-
|
|
13285
|
-
|
|
13286
|
-
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
13290
|
-
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
|
|
13296
|
-
|
|
13297
|
-
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
|
|
13306
|
-
|
|
13307
|
-
|
|
13308
|
-
|
|
13309
|
-
|
|
13310
|
-
|
|
13311
|
-
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
|
|
13807
|
+
// src/scaffold/secure-api-template.ts
|
|
13808
|
+
import { existsSync as existsSync12, lstatSync as lstatSync5, mkdirSync as mkdirSync4, writeFileSync as writeFileSync4 } from "node:fs";
|
|
13809
|
+
import { dirname as dirname8, join as join14, resolve as resolve11 } from "node:path";
|
|
13810
|
+
var SECURE_API_LIB_PATH = "functions/_lib/secure-api.ts";
|
|
13811
|
+
var SECURE_API_ROUTER_PATH = "functions/api/[[path]].ts";
|
|
13812
|
+
var SECURE_API_TEST_PATH = "tests/secure-api.test.ts";
|
|
13813
|
+
var AUTHZ_ATTESTATION_PATH = "authz-attestation.json";
|
|
13814
|
+
var SECURE_TEMPLATE_INCLUDE = ["tests/**", AUTHZ_ATTESTATION_PATH];
|
|
13815
|
+
var AUTHZ_STATEMENT_ID = "launchpad-app-authz-v1";
|
|
13816
|
+
var AUTHZ_STATEMENT = "Every API route verifies the signed-in user with @m-kopa/platform-auth before it runs, " + "every route that changes data checks the caller's role, and new routes are added through " + "createSecureApi with tests/secure-api.test.ts kept in place.";
|
|
13817
|
+
var SECURE_API_LIB = `// Secure-by-default API helpers (scaffolded by \`launchpad init --secure-template\`).
|
|
13818
|
+
//
|
|
13819
|
+
// createSecureApi() registers the identity check FIRST, so every route added
|
|
13820
|
+
// to the returned app runs behind it. requireRole() is the role check for
|
|
13821
|
+
// routes that change data. tests/secure-api.test.ts fails if either is
|
|
13822
|
+
// bypassed. Do not create another Hono app under functions/.
|
|
13823
|
+
|
|
13824
|
+
import { Hono, type MiddlewareHandler } from "hono";
|
|
13825
|
+
import { createJwksCache, parseGatewayAssertionFromHeaders } from "@m-kopa/platform-auth";
|
|
13826
|
+
import { createPlatformAuthMiddleware, type PlatformAuthVariables } from "@m-kopa/platform-auth/hono";
|
|
13827
|
+
|
|
13828
|
+
/**
|
|
13829
|
+
* Bindings the platform sets on a gateway-fronted app. Older Pages apps may
|
|
13830
|
+
* carry only the legacy names (CF_ACCESS_TEAM_DOMAIN, CF_ACCESS_AUD,
|
|
13831
|
+
* JWKS_URL), which hold the same gateway values; both sets are read.
|
|
13832
|
+
*/
|
|
13833
|
+
export interface SecureEnv {
|
|
13834
|
+
GATEWAY_ISSUER?: string;
|
|
13835
|
+
GATEWAY_AUD?: string;
|
|
13836
|
+
GATEWAY_JWKS_URL?: string;
|
|
13837
|
+
CF_ACCESS_TEAM_DOMAIN?: string;
|
|
13838
|
+
CF_ACCESS_AUD?: string;
|
|
13839
|
+
JWKS_URL?: string;
|
|
13840
|
+
[key: string]: unknown;
|
|
13841
|
+
}
|
|
13842
|
+
|
|
13843
|
+
type SecureVars<E extends SecureEnv> = { Bindings: E; Variables: PlatformAuthVariables };
|
|
13844
|
+
export type SecureApp<E extends SecureEnv> = Hono<SecureVars<E>>;
|
|
13845
|
+
|
|
13846
|
+
const authGuards = new WeakSet<object>();
|
|
13847
|
+
const roleGuards = new WeakSet<object>();
|
|
13848
|
+
const passThroughs = new WeakSet<object>();
|
|
13849
|
+
|
|
13850
|
+
/** True for the identity middleware created by createSecureApi (used by the tests). */
|
|
13851
|
+
export function isAuthGuard(handler: unknown): boolean {
|
|
13852
|
+
return typeof handler === "function" && authGuards.has(handler);
|
|
13853
|
+
}
|
|
13854
|
+
|
|
13855
|
+
/** True for a middleware created by requireRole (used by the tests). */
|
|
13856
|
+
export function isRoleGuard(handler: unknown): boolean {
|
|
13857
|
+
return typeof handler === "function" && roleGuards.has(handler);
|
|
13858
|
+
}
|
|
13859
|
+
|
|
13860
|
+
/** True for a middleware marked with passThrough (used by the tests). */
|
|
13861
|
+
export function isPassThrough(handler: unknown): boolean {
|
|
13862
|
+
return typeof handler === "function" && passThroughs.has(handler);
|
|
13863
|
+
}
|
|
13864
|
+
|
|
13865
|
+
/**
|
|
13866
|
+
* Mark a middleware that only observes the request and always calls next()
|
|
13867
|
+
* (logging, headers, timing) so app.use(...) does not need a role check. Never
|
|
13868
|
+
* wrap a handler that answers a request or changes data.
|
|
13869
|
+
*/
|
|
13870
|
+
export function passThrough<H extends MiddlewareHandler<any>>(handler: H): H {
|
|
13871
|
+
passThroughs.add(handler);
|
|
13872
|
+
return handler;
|
|
13873
|
+
}
|
|
13874
|
+
|
|
13875
|
+
let cachedJwks: ReturnType<typeof createJwksCache> | undefined;
|
|
13876
|
+
let cachedJwksUrl: string | undefined;
|
|
13877
|
+
function jwksFor(url: string): ReturnType<typeof createJwksCache> {
|
|
13878
|
+
if (cachedJwks === undefined || cachedJwksUrl !== url) {
|
|
13879
|
+
cachedJwks = createJwksCache(url);
|
|
13880
|
+
cachedJwksUrl = url;
|
|
13318
13881
|
}
|
|
13319
|
-
|
|
13882
|
+
return cachedJwks;
|
|
13883
|
+
}
|
|
13884
|
+
|
|
13885
|
+
function verifyIdentity<E extends SecureEnv>(): MiddlewareHandler<SecureVars<E>> {
|
|
13886
|
+
const guard: MiddlewareHandler<SecureVars<E>> = async (c, next) => {
|
|
13887
|
+
// No assertion: refuse before anything else runs.
|
|
13888
|
+
if (parseGatewayAssertionFromHeaders(c.req.raw.headers) === null) {
|
|
13889
|
+
return c.json({ error: "unauthorized" }, 401);
|
|
13890
|
+
}
|
|
13891
|
+
const issuer = c.env?.GATEWAY_ISSUER || c.env?.CF_ACCESS_TEAM_DOMAIN;
|
|
13892
|
+
const audience = c.env?.GATEWAY_AUD || c.env?.CF_ACCESS_AUD;
|
|
13893
|
+
if (!issuer || !audience) {
|
|
13894
|
+
// Fail closed: never serve a route when the verifier is not configured.
|
|
13895
|
+
return c.json({ error: "identity_not_configured" }, 503);
|
|
13896
|
+
}
|
|
13897
|
+
const jwksUrl =
|
|
13898
|
+
c.env?.GATEWAY_JWKS_URL || c.env?.JWKS_URL || \`\${issuer.replace(/\\/$/, "")}/.well-known/jwks.json\`;
|
|
13899
|
+
// platform-auth types its middleware for its own Variables only; this app
|
|
13900
|
+
// also has Bindings, so the cast widens it to the app's context type.
|
|
13901
|
+
const middleware = createPlatformAuthMiddleware({
|
|
13902
|
+
header: "gateway",
|
|
13903
|
+
teamDomain: issuer,
|
|
13904
|
+
audience,
|
|
13905
|
+
jwks: jwksFor(jwksUrl),
|
|
13906
|
+
}) as unknown as MiddlewareHandler<SecureVars<E>>;
|
|
13907
|
+
return middleware(c, next);
|
|
13908
|
+
};
|
|
13909
|
+
authGuards.add(guard);
|
|
13910
|
+
return guard;
|
|
13911
|
+
}
|
|
13912
|
+
|
|
13913
|
+
/** A Hono app under /api whose first handler verifies the caller's identity. */
|
|
13914
|
+
export function createSecureApi<E extends SecureEnv>(): SecureApp<E> {
|
|
13915
|
+
const app = new Hono<SecureVars<E>>().basePath("/api");
|
|
13916
|
+
app.use("*", verifyIdentity<E>());
|
|
13917
|
+
return app;
|
|
13918
|
+
}
|
|
13919
|
+
|
|
13920
|
+
/**
|
|
13921
|
+
* Allow the request only when the caller is in one of the Entra groups listed
|
|
13922
|
+
* (comma separated group object IDs) in ROLE_<ROLE>_GROUP_IDS. An unset or
|
|
13923
|
+
* empty list denies everyone: set it before the route can be used.
|
|
13924
|
+
*
|
|
13925
|
+
* The groups come from the verified gateway assertion, which is a login-time
|
|
13926
|
+
* snapshot: removing someone from a role group takes effect at their next
|
|
13927
|
+
* gateway sign-in, not at once. Use this for coarse roles (writer, admin).
|
|
13928
|
+
* When revocation must be immediate, look the role up server-side (your own
|
|
13929
|
+
* table or Microsoft Graph) instead.
|
|
13930
|
+
*/
|
|
13931
|
+
export function requireRole<E extends SecureEnv>(role: string): MiddlewareHandler<SecureVars<E>> {
|
|
13932
|
+
const key = \`ROLE_\${role.toUpperCase().replace(/[^A-Z0-9]/g, "_")}_GROUP_IDS\`;
|
|
13933
|
+
const guard: MiddlewareHandler<SecureVars<E>> = async (c, next) => {
|
|
13934
|
+
const allowed = String(c.env?.[key] ?? "")
|
|
13935
|
+
.split(",")
|
|
13936
|
+
.map((g) => g.trim().toLowerCase())
|
|
13937
|
+
.filter((g) => g !== "");
|
|
13938
|
+
const user = c.get("user");
|
|
13939
|
+
const groups = (user?.groups ?? []).map((g) => g.toLowerCase());
|
|
13940
|
+
if (allowed.length === 0 || !groups.some((g) => allowed.includes(g))) {
|
|
13941
|
+
return c.json({ error: "forbidden", role }, 403);
|
|
13942
|
+
}
|
|
13943
|
+
await next();
|
|
13944
|
+
return;
|
|
13945
|
+
};
|
|
13946
|
+
roleGuards.add(guard);
|
|
13947
|
+
return guard;
|
|
13948
|
+
}
|
|
13949
|
+
`;
|
|
13950
|
+
var SECURE_API_ROUTER = `// API router (scaffolded by \`launchpad init --secure-template\`).
|
|
13951
|
+
//
|
|
13952
|
+
// Add every route to the app that buildApp() returns. Routes that change data
|
|
13953
|
+
// need requireRole(...) BEFORE the handler. tests/secure-api.test.ts checks
|
|
13954
|
+
// both. Keep the last line as it is: the guard test checks it.
|
|
13955
|
+
|
|
13956
|
+
import { handle } from "hono/cloudflare-pages";
|
|
13957
|
+
import { createSecureApi, requireRole, type SecureEnv } from "../_lib/secure-api";
|
|
13958
|
+
|
|
13959
|
+
export interface Env extends SecureEnv {
|
|
13960
|
+
/** Comma separated Entra group object IDs allowed to write. */
|
|
13961
|
+
ROLE_WRITER_GROUP_IDS?: string;
|
|
13962
|
+
}
|
|
13963
|
+
|
|
13964
|
+
export function buildApp() {
|
|
13965
|
+
const app = createSecureApi<Env>();
|
|
13966
|
+
|
|
13967
|
+
// Read route: any verified user of this app.
|
|
13968
|
+
app.get("/me", (c) => {
|
|
13969
|
+
const user = c.get("user");
|
|
13970
|
+
return c.json({ sub: user.sub, name: user.name ?? null });
|
|
13971
|
+
});
|
|
13972
|
+
|
|
13973
|
+
// Write route: verified user AND in the writer role.
|
|
13974
|
+
app.post("/items", requireRole<Env>("writer"), async (c) => {
|
|
13975
|
+
return c.json({ ok: true }, 201);
|
|
13976
|
+
});
|
|
13977
|
+
|
|
13978
|
+
return app;
|
|
13979
|
+
}
|
|
13980
|
+
|
|
13981
|
+
export const onRequest = handle(buildApp());
|
|
13982
|
+
`;
|
|
13983
|
+
var SECURE_API_TEST = `// Guard test for the secure API template (audit A2-09). Do not delete.
|
|
13984
|
+
//
|
|
13985
|
+
// Fails when a route escapes the identity middleware, a route that can change
|
|
13986
|
+
// data has no role check in front of it, the router stops exporting the
|
|
13987
|
+
// secure app, or a route file appears outside the secure router.
|
|
13988
|
+
|
|
13989
|
+
import { lstatSync, readdirSync, readFileSync } from "node:fs";
|
|
13990
|
+
import { join, relative } from "node:path";
|
|
13991
|
+
import { describe, expect, test } from "vitest";
|
|
13992
|
+
import { buildApp } from "../functions/api/[[path]]";
|
|
13993
|
+
import { isAuthGuard, isPassThrough, isRoleGuard } from "../functions/_lib/secure-api";
|
|
13994
|
+
|
|
13995
|
+
/** Methods that cannot change data. Everything else, ALL included, is a write. */
|
|
13996
|
+
const READ_METHODS = new Set(["GET", "HEAD", "OPTIONS"]);
|
|
13997
|
+
const ROUTER = "functions/api/[[path]].ts";
|
|
13998
|
+
const LIB = "functions/_lib/secure-api.ts";
|
|
13999
|
+
|
|
14000
|
+
const ROUTE_EXPORT_RX = /export\\s+(?:async\\s+)?(?:function|const|let|var)\\s+onRequest|export\\s*\\{[^}]*\\bonRequest/;
|
|
14001
|
+
const NEW_HONO_RX = /new\\s+Hono\\b/g;
|
|
14002
|
+
|
|
14003
|
+
function honoApps(text: string): number {
|
|
14004
|
+
return (text.match(NEW_HONO_RX) ?? []).length;
|
|
14005
|
+
}
|
|
14006
|
+
|
|
14007
|
+
function samplePath(path: string): string {
|
|
14008
|
+
return path.replace(/:[^/]+/g, "x").replace(/\\*$/, "x");
|
|
14009
|
+
}
|
|
14010
|
+
|
|
14011
|
+
/** True when a guard registered on \`guardPath\` runs for \`path\`. */
|
|
14012
|
+
function covers(guardPath: string, path: string): boolean {
|
|
14013
|
+
if (guardPath === path) return true;
|
|
14014
|
+
if (!guardPath.endsWith("/*")) return false;
|
|
14015
|
+
const prefix = guardPath.slice(0, -1); // keeps the trailing "/"
|
|
14016
|
+
return path.startsWith(prefix) || path === prefix.slice(0, -1);
|
|
14017
|
+
}
|
|
14018
|
+
|
|
14019
|
+
/** Files under dir. A symlink fails the test: it cannot be checked and can loop. */
|
|
14020
|
+
function walk(dir: string, root: string): string[] {
|
|
14021
|
+
let names: string[];
|
|
14022
|
+
try {
|
|
14023
|
+
names = readdirSync(dir);
|
|
14024
|
+
} catch {
|
|
14025
|
+
return [];
|
|
14026
|
+
}
|
|
14027
|
+
return names.flatMap((n) => {
|
|
14028
|
+
const p = join(dir, n);
|
|
14029
|
+
const st = lstatSync(p);
|
|
14030
|
+
expect(st.isSymbolicLink(), \`\${relative(root, p)} is a symlink; the guard test cannot check it\`).toBe(false);
|
|
14031
|
+
return st.isDirectory() ? walk(p, root) : [p];
|
|
14032
|
+
});
|
|
14033
|
+
}
|
|
14034
|
+
|
|
14035
|
+
describe("secure API template", () => {
|
|
14036
|
+
const app = buildApp();
|
|
14037
|
+
const routes = app.routes;
|
|
14038
|
+
|
|
14039
|
+
test("the identity middleware is the first handler and covers every route", () => {
|
|
14040
|
+
expect(isAuthGuard(routes[0]?.handler)).toBe(true);
|
|
14041
|
+
expect(routes[0]?.path).toBe("/api/*");
|
|
14042
|
+
expect(routes.filter((r) => isAuthGuard(r.handler))).toHaveLength(1);
|
|
14043
|
+
});
|
|
14044
|
+
|
|
14045
|
+
test("every route refuses a request without an identity assertion", async () => {
|
|
14046
|
+
for (const r of routes) {
|
|
14047
|
+
if (isAuthGuard(r.handler)) continue;
|
|
14048
|
+
const method = r.method === "ALL" ? "GET" : r.method;
|
|
14049
|
+
const res = await app.request(samplePath(r.path), { method });
|
|
14050
|
+
expect(res.status, \`\${method} \${r.path}\`).toBe(401);
|
|
14051
|
+
}
|
|
14052
|
+
});
|
|
14053
|
+
|
|
14054
|
+
test("every route that can change data has requireRole(...) in front of it", () => {
|
|
14055
|
+
routes.forEach((w, i) => {
|
|
14056
|
+
if (READ_METHODS.has(w.method)) return;
|
|
14057
|
+
if (isAuthGuard(w.handler) || isRoleGuard(w.handler) || isPassThrough(w.handler)) return;
|
|
14058
|
+
// A role guard must run first: registered earlier, for the same method
|
|
14059
|
+
// (or every method), on a path that covers this one. An ALL route needs
|
|
14060
|
+
// an ALL guard, since a POST-only guard leaves DELETE open.
|
|
14061
|
+
const guarded = routes.slice(0, i).some(
|
|
14062
|
+
(g) =>
|
|
14063
|
+
isRoleGuard(g.handler) &&
|
|
14064
|
+
(g.method === "ALL" || (w.method !== "ALL" && g.method === w.method)) &&
|
|
14065
|
+
covers(g.path, w.path),
|
|
14066
|
+
);
|
|
14067
|
+
expect(guarded, \`\${w.method} \${w.path} has no requireRole(...) before its handler (wrap an observe-only middleware in passThrough(...))\`).toBe(true);
|
|
14068
|
+
});
|
|
14069
|
+
});
|
|
14070
|
+
|
|
14071
|
+
test("the router exports the secure app and nothing else", () => {
|
|
14072
|
+
const text = readFileSync(join(process.cwd(), ROUTER), "utf8");
|
|
14073
|
+
expect(text, \`\${ROUTER} must end with: export const onRequest = handle(buildApp());\`).toMatch(
|
|
14074
|
+
/^export const onRequest = handle\\(buildApp\\(\\)\\);$/m,
|
|
14075
|
+
);
|
|
14076
|
+
expect(text.match(/export\\s+(?:async\\s+)?(?:function|const|let|var)\\s+onRequest\\w*/g), ROUTER).toHaveLength(1);
|
|
14077
|
+
expect(/export\\s*\\{[^}]*\\bonRequest|export\\s+default\\b/.test(text), \`\${ROUTER} has another export\`).toBe(false);
|
|
14078
|
+
expect(honoApps(text), \`\${ROUTER} creates its own Hono app\`).toBe(0);
|
|
14079
|
+
const lib = readFileSync(join(process.cwd(), LIB), "utf8");
|
|
14080
|
+
expect(honoApps(lib), \`\${LIB} creates one Hono app (createSecureApi)\`).toBe(1);
|
|
14081
|
+
expect(ROUTE_EXPORT_RX.test(lib), \`\${LIB} exports a route handler\`).toBe(false);
|
|
14082
|
+
});
|
|
14083
|
+
|
|
14084
|
+
test("no route handlers outside the secure router", () => {
|
|
14085
|
+
const root = process.cwd(); // vitest runs from the app root
|
|
14086
|
+
for (const abs of walk(join(root, "functions"), root)) {
|
|
14087
|
+
const rel = relative(root, abs).split("\\\\").join("/");
|
|
14088
|
+
if (rel === ROUTER || rel === LIB || !/\\.(m?[jt]sx?)$/.test(rel)) continue;
|
|
14089
|
+
const text = readFileSync(abs, "utf8");
|
|
14090
|
+
expect(ROUTE_EXPORT_RX.test(text), \`\${rel} exports a route handler\`).toBe(false);
|
|
14091
|
+
expect(honoApps(text), \`\${rel} creates its own Hono app\`).toBe(0);
|
|
14092
|
+
}
|
|
14093
|
+
});
|
|
14094
|
+
});
|
|
14095
|
+
`;
|
|
14096
|
+
function sameEmail(a, b) {
|
|
14097
|
+
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
14098
|
+
}
|
|
14099
|
+
function attestationStatus(input2) {
|
|
14100
|
+
if (input2.attester === undefined)
|
|
14101
|
+
return "pending";
|
|
14102
|
+
return sameEmail(input2.attester.email, input2.owner) ? "attested" : "attested_by_other";
|
|
14103
|
+
}
|
|
14104
|
+
function attestationJson(input2) {
|
|
14105
|
+
const status = attestationStatus(input2);
|
|
14106
|
+
const record = {
|
|
14107
|
+
version: 2,
|
|
14108
|
+
audit_item: "A2-09",
|
|
14109
|
+
statement_id: AUTHZ_STATEMENT_ID,
|
|
14110
|
+
statement: AUTHZ_STATEMENT,
|
|
14111
|
+
status,
|
|
14112
|
+
owner: input2.owner,
|
|
14113
|
+
...input2.attester === undefined ? {} : {
|
|
14114
|
+
attested_by: { oid: input2.attester.oid, email: input2.attester.email },
|
|
14115
|
+
attested_at: input2.date,
|
|
14116
|
+
identity_source: "launchpad session (/me/identity)"
|
|
14117
|
+
},
|
|
14118
|
+
server_recorded: false
|
|
14119
|
+
};
|
|
14120
|
+
return `${JSON.stringify(record, null, 2)}
|
|
14121
|
+
`;
|
|
14122
|
+
}
|
|
14123
|
+
function symlinkOnPath(baseDir, rel) {
|
|
14124
|
+
let cur = resolve11(baseDir);
|
|
14125
|
+
for (const part of rel.split("/")) {
|
|
14126
|
+
cur = join14(cur, part);
|
|
14127
|
+
let st;
|
|
14128
|
+
try {
|
|
14129
|
+
st = lstatSync5(cur);
|
|
14130
|
+
} catch {
|
|
14131
|
+
return false;
|
|
14132
|
+
}
|
|
14133
|
+
if (st.isSymbolicLink())
|
|
14134
|
+
return true;
|
|
14135
|
+
}
|
|
14136
|
+
return false;
|
|
14137
|
+
}
|
|
14138
|
+
function writeSecureApiScaffold(baseDir, attestation) {
|
|
14139
|
+
const files = [
|
|
14140
|
+
[SECURE_API_LIB_PATH, SECURE_API_LIB],
|
|
14141
|
+
[SECURE_API_ROUTER_PATH, SECURE_API_ROUTER],
|
|
14142
|
+
[SECURE_API_TEST_PATH, SECURE_API_TEST],
|
|
14143
|
+
[AUTHZ_ATTESTATION_PATH, attestationJson(attestation)]
|
|
14144
|
+
];
|
|
14145
|
+
const written = [];
|
|
14146
|
+
const kept = [];
|
|
14147
|
+
const skippedSymlink = [];
|
|
14148
|
+
for (const [rel, text2] of files) {
|
|
14149
|
+
if (symlinkOnPath(baseDir, rel)) {
|
|
14150
|
+
skippedSymlink.push(rel);
|
|
14151
|
+
continue;
|
|
14152
|
+
}
|
|
14153
|
+
const abs = resolve11(baseDir, rel);
|
|
14154
|
+
if (existsSync12(abs)) {
|
|
14155
|
+
kept.push(rel);
|
|
14156
|
+
continue;
|
|
14157
|
+
}
|
|
14158
|
+
mkdirSync4(dirname8(abs), { recursive: true });
|
|
14159
|
+
writeFileSync4(abs, text2, { encoding: "utf8", flag: "wx" });
|
|
14160
|
+
written.push(rel);
|
|
14161
|
+
}
|
|
14162
|
+
return { written, kept, skippedSymlink };
|
|
14163
|
+
}
|
|
14164
|
+
function writeAttestation(baseDir, attestation) {
|
|
14165
|
+
if (symlinkOnPath(baseDir, AUTHZ_ATTESTATION_PATH))
|
|
14166
|
+
return false;
|
|
14167
|
+
writeFileSync4(resolve11(baseDir, AUTHZ_ATTESTATION_PATH), attestationJson(attestation), { encoding: "utf8" });
|
|
14168
|
+
return true;
|
|
14169
|
+
}
|
|
14170
|
+
|
|
14171
|
+
// src/commands/init.ts
|
|
14172
|
+
var SLUG_REGEX3 = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
|
|
14173
|
+
var initCommand = {
|
|
14174
|
+
name: "init",
|
|
14175
|
+
summary: "scaffold a new launchpad.yaml in the current directory",
|
|
14176
|
+
run: (args, io) => runInit(args, io, defaultPrompt3)
|
|
14177
|
+
};
|
|
14178
|
+
async function runInit(args, io, prompt, identity = () => apiJson(loadConfig(), { path: "/me/identity" })) {
|
|
14179
|
+
const parsed = parseArgs6(args);
|
|
14180
|
+
if (parsed.kind === "usage-error") {
|
|
14181
|
+
io.err(`launchpad init: ${parsed.message}`);
|
|
14182
|
+
io.err("Usage: launchpad init [--non-interactive] [flags]");
|
|
14183
|
+
return 64;
|
|
14184
|
+
}
|
|
14185
|
+
const { inputs, options } = parsed;
|
|
14186
|
+
const outPath = resolve12(process.cwd(), options.out);
|
|
14187
|
+
if (options.attestAuthz && !options.secureTemplate) {
|
|
14188
|
+
return attestExistingScaffold(outPath, io, identity);
|
|
14189
|
+
}
|
|
14190
|
+
if (existsSync13(outPath) && !options.force) {
|
|
14191
|
+
io.err(`launchpad init: ${outPath} already exists`);
|
|
14192
|
+
io.err("Pass --force to overwrite.");
|
|
14193
|
+
return 64;
|
|
14194
|
+
}
|
|
14195
|
+
let detected;
|
|
14196
|
+
if (!options.skipDetect && inputs.type !== "container") {
|
|
14197
|
+
const detectResult = detectAppShape(process.cwd());
|
|
14198
|
+
if (detectResult.kind === "ok") {
|
|
14199
|
+
detected = detectResult.detected;
|
|
14200
|
+
if (inputs.type === undefined) {
|
|
14201
|
+
inputs.type = detected.appType;
|
|
14202
|
+
}
|
|
14203
|
+
} else if (detectResult.kind === "ambiguous" && inputs.type === undefined) {
|
|
14204
|
+
io.err(`launchpad init: cannot detect app shape from current directory`);
|
|
14205
|
+
io.err(` ${detectResult.reason}`);
|
|
14206
|
+
io.err(``);
|
|
14207
|
+
io.err(`If you know the app type, pass --type (one of: ${APP_TYPES2.join(", ")}) to bypass detection,`);
|
|
14208
|
+
io.err(`or pass --no-detect to skip detection entirely.`);
|
|
14209
|
+
return 64;
|
|
14210
|
+
}
|
|
14211
|
+
}
|
|
14212
|
+
const fillResult = await fillRequired(inputs, options, io, prompt);
|
|
14213
|
+
if (fillResult.kind === "usage-error") {
|
|
14214
|
+
io.err(`launchpad init: ${fillResult.message}`);
|
|
14215
|
+
return 64;
|
|
14216
|
+
}
|
|
14217
|
+
if (options.secureTemplate && fillResult.inputs.type !== "react+api") {
|
|
14218
|
+
io.err(`launchpad init: --secure-template scaffolds an API and needs --type react+api (got ${fillResult.inputs.type})`);
|
|
14219
|
+
return 64;
|
|
14220
|
+
}
|
|
14221
|
+
const authIssue = deploymentAuthIssue(fillResult.inputs.type, fillResult.inputs.auth ?? "gateway");
|
|
13320
14222
|
if (authIssue !== null) {
|
|
13321
14223
|
io.err(`launchpad init: ${authIssue.message}`);
|
|
13322
14224
|
return 64;
|
|
@@ -13343,7 +14245,7 @@ async function runInit(args, io, prompt, identity = () => apiJson(loadConfig(),
|
|
|
13343
14245
|
io.out(`Audience: selected Entra groups (${fillResult.inputs.groups.join(", ")}), plus platform administrators.`);
|
|
13344
14246
|
io.out("The deploy skill confirms company-wide grants with you. Sensitive apps also require browser confirmation and platform-admin approval.");
|
|
13345
14247
|
}
|
|
13346
|
-
const manifest = buildManifest({ ...fillResult.inputs, ...privateOwner === undefined ? {} : { privateOwner } }, detected);
|
|
14248
|
+
const manifest = buildManifest({ ...fillResult.inputs, ...privateOwner === undefined ? {} : { privateOwner } }, detected, options.secureTemplate ? SECURE_TEMPLATE_INCLUDE : []);
|
|
13347
14249
|
const validation = manifest.apiVersion === "launchpad.m-kopa.us/v2" ? ManifestV2Schema.safeParse(manifest) : ManifestSchema.safeParse(manifest);
|
|
13348
14250
|
if (!validation.success) {
|
|
13349
14251
|
io.err("launchpad init: invalid manifest input");
|
|
@@ -13354,7 +14256,7 @@ async function runInit(args, io, prompt, identity = () => apiJson(loadConfig(),
|
|
|
13354
14256
|
}
|
|
13355
14257
|
const yamlText = renderYaml(manifest);
|
|
13356
14258
|
try {
|
|
13357
|
-
|
|
14259
|
+
writeFileSync5(outPath, yamlText, { encoding: "utf8" });
|
|
13358
14260
|
} catch (err) {
|
|
13359
14261
|
const e = err;
|
|
13360
14262
|
io.err(`launchpad init: failed to write ${outPath}`);
|
|
@@ -13363,7 +14265,7 @@ async function runInit(args, io, prompt, identity = () => apiJson(loadConfig(),
|
|
|
13363
14265
|
}
|
|
13364
14266
|
io.out(`✓ wrote ${outPath}`);
|
|
13365
14267
|
if (options.gitignore) {
|
|
13366
|
-
const gitignorePath =
|
|
14268
|
+
const gitignorePath = resolve12(process.cwd(), ".gitignore");
|
|
13367
14269
|
try {
|
|
13368
14270
|
const changed = ensureGitignoreEntries(gitignorePath, [".env", ".env.local"]);
|
|
13369
14271
|
if (changed.length > 0) {
|
|
@@ -13378,12 +14280,12 @@ async function runInit(args, io, prompt, identity = () => apiJson(loadConfig(),
|
|
|
13378
14280
|
}
|
|
13379
14281
|
}
|
|
13380
14282
|
if (fillResult.inputs.type === "static") {
|
|
13381
|
-
const serveDir =
|
|
13382
|
-
const indexPath =
|
|
13383
|
-
if (!
|
|
14283
|
+
const serveDir = resolve12(dirname9(outPath), STATIC_SERVE_DIR);
|
|
14284
|
+
const indexPath = resolve12(serveDir, "index.html");
|
|
14285
|
+
if (!existsSync13(indexPath)) {
|
|
13384
14286
|
try {
|
|
13385
|
-
|
|
13386
|
-
|
|
14287
|
+
mkdirSync5(serveDir, { recursive: true });
|
|
14288
|
+
writeFileSync5(indexPath, starterIndexHtml(fillResult.inputs.name), {
|
|
13387
14289
|
encoding: "utf8"
|
|
13388
14290
|
});
|
|
13389
14291
|
io.out(`✓ scaffolded ${indexPath}`);
|
|
@@ -13394,6 +14296,11 @@ async function runInit(args, io, prompt, identity = () => apiJson(loadConfig(),
|
|
|
13394
14296
|
}
|
|
13395
14297
|
}
|
|
13396
14298
|
}
|
|
14299
|
+
if (options.secureTemplate) {
|
|
14300
|
+
const code = await scaffoldSecureTemplate(dirname9(outPath), fillResult.inputs.owner, options, io, prompt, identity);
|
|
14301
|
+
if (code !== 0)
|
|
14302
|
+
return code;
|
|
14303
|
+
}
|
|
13397
14304
|
io.out("");
|
|
13398
14305
|
io.out("Next steps:");
|
|
13399
14306
|
io.out(" launchpad validate # confirm the manifest");
|
|
@@ -13423,6 +14330,8 @@ function parseArgs6(args) {
|
|
|
13423
14330
|
let out = "launchpad.yaml";
|
|
13424
14331
|
let gitignore = true;
|
|
13425
14332
|
let skipDetect = false;
|
|
14333
|
+
let secureTemplate = false;
|
|
14334
|
+
let attestAuthz = false;
|
|
13426
14335
|
for (let i = 0;i < args.length; i++) {
|
|
13427
14336
|
const a = args[i];
|
|
13428
14337
|
switch (a) {
|
|
@@ -13441,6 +14350,12 @@ function parseArgs6(args) {
|
|
|
13441
14350
|
case "--no-detect":
|
|
13442
14351
|
skipDetect = true;
|
|
13443
14352
|
continue;
|
|
14353
|
+
case "--secure-template":
|
|
14354
|
+
secureTemplate = true;
|
|
14355
|
+
continue;
|
|
14356
|
+
case "--attest-authz":
|
|
14357
|
+
attestAuthz = true;
|
|
14358
|
+
continue;
|
|
13444
14359
|
default:
|
|
13445
14360
|
break;
|
|
13446
14361
|
}
|
|
@@ -13574,7 +14489,7 @@ function parseArgs6(args) {
|
|
|
13574
14489
|
return {
|
|
13575
14490
|
kind: "ok",
|
|
13576
14491
|
inputs,
|
|
13577
|
-
options: { force, nonInteractive, out, gitignore, skipDetect }
|
|
14492
|
+
options: { force, nonInteractive, out, gitignore, skipDetect, secureTemplate, attestAuthz }
|
|
13578
14493
|
};
|
|
13579
14494
|
}
|
|
13580
14495
|
async function fillRequired(inputs, options, io, prompt) {
|
|
@@ -13698,7 +14613,7 @@ async function fillRequired(inputs, options, io, prompt) {
|
|
|
13698
14613
|
}
|
|
13699
14614
|
};
|
|
13700
14615
|
}
|
|
13701
|
-
function buildManifest(inputs, detected) {
|
|
14616
|
+
function buildManifest(inputs, detected, extraInclude = []) {
|
|
13702
14617
|
const metadata = {
|
|
13703
14618
|
name: inputs.name,
|
|
13704
14619
|
team: inputs.team,
|
|
@@ -13748,7 +14663,7 @@ function buildManifest(inputs, detected) {
|
|
|
13748
14663
|
}
|
|
13749
14664
|
manifest.app = {
|
|
13750
14665
|
root: ".",
|
|
13751
|
-
include: [...defaultIncludeForAppType(inputs.type)]
|
|
14666
|
+
include: [...defaultIncludeForAppType(inputs.type), ...extraInclude]
|
|
13752
14667
|
};
|
|
13753
14668
|
if (newAppOrigin(inputs.type, inputs.origin) === "dispatch") {
|
|
13754
14669
|
return {
|
|
@@ -13801,9 +14716,120 @@ function starterIndexHtml(slug) {
|
|
|
13801
14716
|
function renderYaml(manifest) {
|
|
13802
14717
|
return yamlStringify(manifest, { lineWidth: 0 });
|
|
13803
14718
|
}
|
|
14719
|
+
async function verifiedAttester(io, identity) {
|
|
14720
|
+
try {
|
|
14721
|
+
const who = await identity();
|
|
14722
|
+
if (typeof who?.email !== "string" || who.email.trim() === "" || typeof who.oid !== "string") {
|
|
14723
|
+
throw new Error("the session has no verified email");
|
|
14724
|
+
}
|
|
14725
|
+
return { oid: who.oid, email: who.email };
|
|
14726
|
+
} catch (error) {
|
|
14727
|
+
io.err(` cannot verify who is attesting (${error instanceof Error ? error.message : String(error)}); run \`launchpad login\` first`);
|
|
14728
|
+
return;
|
|
14729
|
+
}
|
|
14730
|
+
}
|
|
14731
|
+
function reportAttestation(input2, io) {
|
|
14732
|
+
const status = attestationStatus(input2);
|
|
14733
|
+
if (status === "attested") {
|
|
14734
|
+
io.out(`✓ authorisation statement attested by the owner ${input2.owner} (${AUTHZ_ATTESTATION_PATH})`);
|
|
14735
|
+
return;
|
|
14736
|
+
}
|
|
14737
|
+
if (status === "attested_by_other") {
|
|
14738
|
+
io.err(`⚠ you are signed in as ${input2.attester?.email ?? "(unknown)"}, not the owner ${input2.owner}: recorded as attested_by_other, not attested`);
|
|
14739
|
+
} else {
|
|
14740
|
+
io.out("⚠ authorisation statement pending");
|
|
14741
|
+
}
|
|
14742
|
+
io.out(` The owner (${input2.owner}) attests by running \`launchpad init --attest-authz\` here while signed in as themselves.`);
|
|
14743
|
+
io.out(` Do not edit ${AUTHZ_ATTESTATION_PATH} by hand: only a record written from the owner's session counts.`);
|
|
14744
|
+
}
|
|
14745
|
+
async function scaffoldSecureTemplate(baseDir, owner, options, io, prompt, identity) {
|
|
14746
|
+
let attests = options.attestAuthz;
|
|
14747
|
+
if (!attests && !options.nonInteractive) {
|
|
14748
|
+
io.out("");
|
|
14749
|
+
io.out("Owner attestation (audit A2-09):");
|
|
14750
|
+
io.out(` ${AUTHZ_STATEMENT}`);
|
|
14751
|
+
const answer = await prompt("Do you, as the app owner, attest this statement? (yes/no): ", "no");
|
|
14752
|
+
attests = /^y(es)?$/i.test(answer.trim());
|
|
14753
|
+
}
|
|
14754
|
+
const attester = attests ? await verifiedAttester(io, identity) : undefined;
|
|
14755
|
+
const attestation = {
|
|
14756
|
+
owner,
|
|
14757
|
+
date: new Date().toISOString().slice(0, 10),
|
|
14758
|
+
...attester === undefined ? {} : { attester }
|
|
14759
|
+
};
|
|
14760
|
+
let result;
|
|
14761
|
+
try {
|
|
14762
|
+
result = writeSecureApiScaffold(baseDir, attestation);
|
|
14763
|
+
} catch (err) {
|
|
14764
|
+
const e = err;
|
|
14765
|
+
io.err(`launchpad init: failed to write the secure API template: ${e.message ?? String(err)}`);
|
|
14766
|
+
return 2;
|
|
14767
|
+
}
|
|
14768
|
+
for (const p of result.written)
|
|
14769
|
+
io.out(`✓ scaffolded ${p}`);
|
|
14770
|
+
for (const p of result.kept)
|
|
14771
|
+
io.out(` kept existing ${p} (not overwritten)`);
|
|
14772
|
+
for (const p of result.skippedSymlink)
|
|
14773
|
+
io.err(` skipped ${p}: a symlink is on its path`);
|
|
14774
|
+
if (result.written.includes(AUTHZ_ATTESTATION_PATH))
|
|
14775
|
+
reportAttestation(attestation, io);
|
|
14776
|
+
io.out(" Install: npm install hono @m-kopa/platform-auth && npm install -D vitest");
|
|
14777
|
+
io.out(" Set ROLE_WRITER_GROUP_IDS (Entra group object IDs) before the write route accepts anyone.");
|
|
14778
|
+
io.out(" Run the guard test: npx vitest run tests/secure-api.test.ts");
|
|
14779
|
+
return 0;
|
|
14780
|
+
}
|
|
14781
|
+
function existingStatus(path11) {
|
|
14782
|
+
try {
|
|
14783
|
+
const record = JSON.parse(readFileSync17(path11, "utf8"));
|
|
14784
|
+
return typeof record?.status === "string" ? record.status : undefined;
|
|
14785
|
+
} catch {
|
|
14786
|
+
return;
|
|
14787
|
+
}
|
|
14788
|
+
}
|
|
14789
|
+
async function attestExistingScaffold(outPath, io, identity) {
|
|
14790
|
+
const baseDir = dirname9(outPath);
|
|
14791
|
+
if (!existsSync13(resolve12(baseDir, AUTHZ_ATTESTATION_PATH))) {
|
|
14792
|
+
io.err(`launchpad init: --attest-authz needs --secure-template, or an existing ${AUTHZ_ATTESTATION_PATH} beside the manifest`);
|
|
14793
|
+
return 64;
|
|
14794
|
+
}
|
|
14795
|
+
let owner;
|
|
14796
|
+
try {
|
|
14797
|
+
const manifest = yamlParse(readFileSync17(outPath, "utf8"));
|
|
14798
|
+
owner = manifest?.spec?.owner?.email ?? manifest?.metadata?.owner;
|
|
14799
|
+
} catch (err) {
|
|
14800
|
+
io.err(`launchpad init: cannot read ${outPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
14801
|
+
return 64;
|
|
14802
|
+
}
|
|
14803
|
+
if (typeof owner !== "string" || owner.trim() === "") {
|
|
14804
|
+
io.err(`launchpad init: ${outPath} has no owner (spec.owner.email or metadata.owner) to attest for`);
|
|
14805
|
+
return 64;
|
|
14806
|
+
}
|
|
14807
|
+
const attester = await verifiedAttester(io, identity);
|
|
14808
|
+
if (attester === undefined) {
|
|
14809
|
+
io.err("launchpad init: attestation not recorded");
|
|
14810
|
+
return 1;
|
|
14811
|
+
}
|
|
14812
|
+
const attestation = { owner, date: new Date().toISOString().slice(0, 10), attester };
|
|
14813
|
+
if (attestationStatus(attestation) !== "attested" && existingStatus(resolve12(baseDir, AUTHZ_ATTESTATION_PATH)) === "attested") {
|
|
14814
|
+
reportAttestation(attestation, io);
|
|
14815
|
+
io.err("launchpad init: the owner has already attested; not replaced");
|
|
14816
|
+
return 1;
|
|
14817
|
+
}
|
|
14818
|
+
try {
|
|
14819
|
+
if (!writeAttestation(baseDir, attestation)) {
|
|
14820
|
+
io.err(`launchpad init: ${AUTHZ_ATTESTATION_PATH} is a symlink; not written`);
|
|
14821
|
+
return 2;
|
|
14822
|
+
}
|
|
14823
|
+
} catch (err) {
|
|
14824
|
+
io.err(`launchpad init: failed to write ${AUTHZ_ATTESTATION_PATH}: ${err instanceof Error ? err.message : String(err)}`);
|
|
14825
|
+
return 2;
|
|
14826
|
+
}
|
|
14827
|
+
reportAttestation(attestation, io);
|
|
14828
|
+
return attestationStatus(attestation) === "attested" ? 0 : 1;
|
|
14829
|
+
}
|
|
13804
14830
|
function ensureGitignoreEntries(path11, entries) {
|
|
13805
14831
|
let current = "";
|
|
13806
|
-
if (
|
|
14832
|
+
if (existsSync13(path11)) {
|
|
13807
14833
|
current = readFileSync17(path11, "utf8");
|
|
13808
14834
|
}
|
|
13809
14835
|
const lines = current.split(/\r?\n/);
|
|
@@ -13822,7 +14848,7 @@ function ensureGitignoreEntries(path11, entries) {
|
|
|
13822
14848
|
}
|
|
13823
14849
|
}
|
|
13824
14850
|
if (added.length > 0) {
|
|
13825
|
-
|
|
14851
|
+
writeFileSync5(path11, out, { encoding: "utf8" });
|
|
13826
14852
|
}
|
|
13827
14853
|
return added;
|
|
13828
14854
|
}
|
|
@@ -13839,10 +14865,217 @@ async function defaultPrompt3(question, fallback) {
|
|
|
13839
14865
|
}
|
|
13840
14866
|
}
|
|
13841
14867
|
|
|
14868
|
+
// src/commands/agreement.ts
|
|
14869
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
14870
|
+
|
|
14871
|
+
// src/io/prompt.ts
|
|
14872
|
+
function isInteractive() {
|
|
14873
|
+
return Boolean(process.stdin.isTTY);
|
|
14874
|
+
}
|
|
14875
|
+
async function defaultPrompt4(question) {
|
|
14876
|
+
const { createInterface: createInterface3 } = await import("node:readline/promises");
|
|
14877
|
+
const rl = createInterface3({ input: process.stdin, output: process.stdout });
|
|
14878
|
+
try {
|
|
14879
|
+
return await rl.question(question);
|
|
14880
|
+
} finally {
|
|
14881
|
+
rl.close();
|
|
14882
|
+
}
|
|
14883
|
+
}
|
|
14884
|
+
|
|
14885
|
+
// src/commands/agreement.ts
|
|
14886
|
+
var REAL_DEPS = {
|
|
14887
|
+
fetcher: (input2, init) => fetch(input2, init),
|
|
14888
|
+
isInteractive,
|
|
14889
|
+
prompt: defaultPrompt4,
|
|
14890
|
+
loadConfig
|
|
14891
|
+
};
|
|
14892
|
+
var agreementCommand = makeAgreementCommand();
|
|
14893
|
+
function makeAgreementCommand(deps = REAL_DEPS) {
|
|
14894
|
+
return {
|
|
14895
|
+
name: "agreement",
|
|
14896
|
+
summary: "read, accept or check the Launchpad access agreement",
|
|
14897
|
+
run: (args, io) => runAgreement(args, io, deps)
|
|
14898
|
+
};
|
|
14899
|
+
}
|
|
14900
|
+
function acceptancePhrase(version) {
|
|
14901
|
+
return `I accept version ${version}`;
|
|
14902
|
+
}
|
|
14903
|
+
async function runAgreement(args, io, deps) {
|
|
14904
|
+
const sub = args[0];
|
|
14905
|
+
if (sub === undefined || sub === "--help" || sub === "-h" || args.includes("--help")) {
|
|
14906
|
+
printHelp3(io);
|
|
14907
|
+
return sub === undefined ? 64 : 0;
|
|
14908
|
+
}
|
|
14909
|
+
try {
|
|
14910
|
+
const cfg = deps.loadConfig();
|
|
14911
|
+
switch (sub) {
|
|
14912
|
+
case "status":
|
|
14913
|
+
return await runStatus2(cfg, io, deps, args.includes("--json"));
|
|
14914
|
+
case "show":
|
|
14915
|
+
return await runShow2(cfg, io, deps);
|
|
14916
|
+
case "accept":
|
|
14917
|
+
return await runAccept(cfg, io, deps);
|
|
14918
|
+
default:
|
|
14919
|
+
io.err(`launchpad agreement: unknown subcommand "${sub}"`);
|
|
14920
|
+
printHelp3(io);
|
|
14921
|
+
return 64;
|
|
14922
|
+
}
|
|
14923
|
+
} catch (error) {
|
|
14924
|
+
io.err(`launchpad agreement ${sub}: ${describe23(error)}`);
|
|
14925
|
+
return 1;
|
|
14926
|
+
}
|
|
14927
|
+
}
|
|
14928
|
+
async function runStatus2(cfg, io, deps, json) {
|
|
14929
|
+
const status = await apiJson(cfg, { path: "/agreement/status" }, deps.fetcher);
|
|
14930
|
+
if (json) {
|
|
14931
|
+
io.out(JSON.stringify(status, null, 2));
|
|
14932
|
+
return 0;
|
|
14933
|
+
}
|
|
14934
|
+
io.out(`Agreement version: ${status.version}${status.approved ? "" : " (not approved yet)"}`);
|
|
14935
|
+
io.out(`State: ${status.state}`);
|
|
14936
|
+
if (status.acceptedVersion !== null) {
|
|
14937
|
+
io.out(`Accepted version: ${status.acceptedVersion}`);
|
|
14938
|
+
}
|
|
14939
|
+
if (status.acceptedAt !== null)
|
|
14940
|
+
io.out(`Accepted on: ${status.acceptedAt.slice(0, 10)}`);
|
|
14941
|
+
if (status.expiresAt !== null)
|
|
14942
|
+
io.out(`Expires on: ${status.expiresAt.slice(0, 10)}`);
|
|
14943
|
+
if (status.graceUntil !== null)
|
|
14944
|
+
io.out(`Re-accept by: ${status.graceUntil.slice(0, 10)}`);
|
|
14945
|
+
const next = nextStepLine(status);
|
|
14946
|
+
if (next !== null)
|
|
14947
|
+
io.out(next);
|
|
14948
|
+
return 0;
|
|
14949
|
+
}
|
|
14950
|
+
async function runShow2(cfg, io, deps) {
|
|
14951
|
+
const agreement = await apiJson(cfg, { path: "/agreement" }, deps.fetcher);
|
|
14952
|
+
io.out(agreement.text);
|
|
14953
|
+
io.out("");
|
|
14954
|
+
io.out(`Version ${agreement.version}${agreement.approved ? "" : " (not approved yet)"}`);
|
|
14955
|
+
io.out(`SHA-256 ${agreement.sha256}`);
|
|
14956
|
+
return 0;
|
|
14957
|
+
}
|
|
14958
|
+
async function runAccept(cfg, io, deps) {
|
|
14959
|
+
if (!deps.isInteractive()) {
|
|
14960
|
+
io.err("launchpad agreement accept: a person must accept in an interactive terminal. " + "If you are an AI agent, stop and ask the human to run `launchpad agreement accept` themselves.");
|
|
14961
|
+
return 1;
|
|
14962
|
+
}
|
|
14963
|
+
const agreement = await apiJson(cfg, { path: "/agreement" }, deps.fetcher);
|
|
14964
|
+
if (!agreement.approved) {
|
|
14965
|
+
io.err(`Agreement ${agreement.version} is not approved yet, so there is nothing to accept. ` + "You can read the draft with `launchpad agreement show`.");
|
|
14966
|
+
return 1;
|
|
14967
|
+
}
|
|
14968
|
+
const shownSha256 = agreementTextSha256(agreement.text);
|
|
14969
|
+
if (shownSha256 !== agreement.sha256) {
|
|
14970
|
+
io.err("Not accepted: the agreement text does not match the hash the bot reported. " + "Nothing was recorded. Try again, and run `launchpad bug` if it keeps happening.");
|
|
14971
|
+
return 1;
|
|
14972
|
+
}
|
|
14973
|
+
io.out(agreement.text);
|
|
14974
|
+
io.out("");
|
|
14975
|
+
io.out(`Version ${agreement.version}, SHA-256 ${shownSha256}`);
|
|
14976
|
+
io.out("");
|
|
14977
|
+
const phrase = acceptancePhrase(agreement.version);
|
|
14978
|
+
const typed = await deps.prompt(`To accept, type exactly "${phrase}": `);
|
|
14979
|
+
if (typed.trim() !== phrase) {
|
|
14980
|
+
io.err("Not accepted: the phrase did not match. Nothing was recorded.");
|
|
14981
|
+
return 1;
|
|
14982
|
+
}
|
|
14983
|
+
const res = await apiRaw(cfg, {
|
|
14984
|
+
method: "POST",
|
|
14985
|
+
path: "/agreement/accept",
|
|
14986
|
+
jsonBody: { version: agreement.version, sha256: shownSha256, phrase: typed.trim() },
|
|
14987
|
+
nonThrowingStatuses: [400, 409, 503]
|
|
14988
|
+
}, deps.fetcher);
|
|
14989
|
+
const body = await res.json().catch(() => ({}));
|
|
14990
|
+
if (!res.ok) {
|
|
14991
|
+
const message = typeof body.message === "string" ? body.message : `HTTP ${res.status}`;
|
|
14992
|
+
io.err(`Not accepted: ${message}`);
|
|
14993
|
+
return 1;
|
|
14994
|
+
}
|
|
14995
|
+
const expires = typeof body.expiresAt === "string" ? body.expiresAt.slice(0, 10) : "(unknown)";
|
|
14996
|
+
io.out(`Agreement ${agreement.version} accepted. Valid until ${expires}.`);
|
|
14997
|
+
return 0;
|
|
14998
|
+
}
|
|
14999
|
+
function agreementTextSha256(text2) {
|
|
15000
|
+
return createHash3("sha256").update(text2, "utf8").digest("hex");
|
|
15001
|
+
}
|
|
15002
|
+
function nextStepLine(status) {
|
|
15003
|
+
if (!status.approved)
|
|
15004
|
+
return null;
|
|
15005
|
+
switch (status.state) {
|
|
15006
|
+
case "current":
|
|
15007
|
+
return null;
|
|
15008
|
+
case "expiring":
|
|
15009
|
+
return `Your Launchpad agreement expires on ${status.expiresAt?.slice(0, 10) ?? "(soon)"}. Run \`launchpad agreement accept\`.`;
|
|
15010
|
+
case "grace":
|
|
15011
|
+
return `Agreement ${status.version} has changed. Accept it by ${status.graceUntil?.slice(0, 10) ?? "(soon)"}: run \`launchpad agreement accept\`.`;
|
|
15012
|
+
case "expired":
|
|
15013
|
+
return "Your Launchpad agreement has expired. Run `launchpad agreement accept`.";
|
|
15014
|
+
default:
|
|
15015
|
+
return `Before you can deploy, read and accept the Launchpad access agreement (version ${status.version}): run \`launchpad agreement accept\`.`;
|
|
15016
|
+
}
|
|
15017
|
+
}
|
|
15018
|
+
async function printAgreementLoginNotice(io, deps = REAL_DEPS, timeoutMs = 5000) {
|
|
15019
|
+
const faultBefore = peekFault();
|
|
15020
|
+
const restoreFault = () => {
|
|
15021
|
+
if (faultBefore === null)
|
|
15022
|
+
clearFault();
|
|
15023
|
+
else
|
|
15024
|
+
recordFault(faultBefore);
|
|
15025
|
+
};
|
|
15026
|
+
try {
|
|
15027
|
+
const cfg = deps.loadConfig();
|
|
15028
|
+
const request = apiJson(cfg, { path: "/agreement/status", signal: AbortSignal.timeout(timeoutMs) }, deps.fetcher).then((status2) => {
|
|
15029
|
+
restoreFault();
|
|
15030
|
+
return status2;
|
|
15031
|
+
}, () => {
|
|
15032
|
+
restoreFault();
|
|
15033
|
+
return null;
|
|
15034
|
+
});
|
|
15035
|
+
const status = await Promise.race([
|
|
15036
|
+
request,
|
|
15037
|
+
new Promise((resolve13) => setTimeout(() => resolve13(null), timeoutMs).unref?.())
|
|
15038
|
+
]);
|
|
15039
|
+
if (status === null)
|
|
15040
|
+
return;
|
|
15041
|
+
const line = nextStepLine(status);
|
|
15042
|
+
if (line === null)
|
|
15043
|
+
return;
|
|
15044
|
+
io.out("");
|
|
15045
|
+
io.out(line);
|
|
15046
|
+
io.out("An AI agent must not accept for you: open a terminal and run it yourself.");
|
|
15047
|
+
} catch {
|
|
15048
|
+
restoreFault();
|
|
15049
|
+
}
|
|
15050
|
+
}
|
|
15051
|
+
function printHelp3(io) {
|
|
15052
|
+
io.out("launchpad agreement — the Launchpad access agreement.");
|
|
15053
|
+
io.out("");
|
|
15054
|
+
io.out("Usage:");
|
|
15055
|
+
io.out(" launchpad agreement status [--json] Your state against the current version");
|
|
15056
|
+
io.out(" launchpad agreement show Print the current text and its SHA-256");
|
|
15057
|
+
io.out(" launchpad agreement accept Read the text and accept it (interactive terminal only)");
|
|
15058
|
+
io.out("");
|
|
15059
|
+
io.out("You accept once a year, and again when the text changes in a material way.");
|
|
15060
|
+
io.out("An AI agent may not accept for you.");
|
|
15061
|
+
io.out("");
|
|
15062
|
+
io.out("Exit codes:");
|
|
15063
|
+
io.out(" 0 success");
|
|
15064
|
+
io.out(" 1 refused or failed");
|
|
15065
|
+
io.out(" 64 usage error");
|
|
15066
|
+
}
|
|
15067
|
+
function describe23(error) {
|
|
15068
|
+
return error instanceof Error ? error.message : String(error);
|
|
15069
|
+
}
|
|
15070
|
+
|
|
13842
15071
|
// src/commands/login.ts
|
|
13843
|
-
var
|
|
15072
|
+
var REAL_DEPS2 = {
|
|
15073
|
+
gatewayLogin,
|
|
15074
|
+
legacyLogin: login,
|
|
15075
|
+
agreementNotice: (io) => printAgreementLoginNotice(io)
|
|
15076
|
+
};
|
|
13844
15077
|
var loginCommand = makeLoginCommand();
|
|
13845
|
-
function makeLoginCommand(deps =
|
|
15078
|
+
function makeLoginCommand(deps = REAL_DEPS2) {
|
|
13846
15079
|
return {
|
|
13847
15080
|
name: "login",
|
|
13848
15081
|
summary: "authenticate (browser-based PKCE) and store a session",
|
|
@@ -13875,15 +15108,16 @@ async function runLogin(args, io, deps) {
|
|
|
13875
15108
|
const expiresIn = Math.max(0, Math.round((session.accessTokenExpiresAt - Date.now()) / 1000));
|
|
13876
15109
|
io.out(`Logged in. Session stored at ${cfg.sessionPath}`);
|
|
13877
15110
|
io.out(`Access token expires in ~${expiresIn}s; refreshes silently.`);
|
|
15111
|
+
await agreementNoticeSafely(deps, io);
|
|
13878
15112
|
return 0;
|
|
13879
15113
|
} catch (e) {
|
|
13880
|
-
io.err(`Gateway login failed: ${
|
|
15114
|
+
io.err(`Gateway login failed: ${describe24(e)}`);
|
|
13881
15115
|
io.err("Falling back to the legacy Cloudflare Access flow (DEPRECATED — this fallback will be removed when the dual-auth window closes).");
|
|
13882
15116
|
io.err("");
|
|
13883
15117
|
return await runLegacyLogin(io, cfg.botUrl, cfg.sessionPath, deps);
|
|
13884
15118
|
}
|
|
13885
15119
|
} catch (e) {
|
|
13886
|
-
io.err(`launchpad login failed: ${
|
|
15120
|
+
io.err(`launchpad login failed: ${describe24(e)}`);
|
|
13887
15121
|
return 1;
|
|
13888
15122
|
}
|
|
13889
15123
|
}
|
|
@@ -13902,6 +15136,7 @@ async function runLegacyLogin(io, botUrl, sessionPath, deps) {
|
|
|
13902
15136
|
const expiresIn = Math.max(0, Math.round((session.accessTokenExpiresAt - Date.now()) / 1000));
|
|
13903
15137
|
io.out(`Logged in. Session stored at ${sessionPath}`);
|
|
13904
15138
|
io.out(`Access token expires in ~${expiresIn}s; refreshes silently.`);
|
|
15139
|
+
await agreementNoticeSafely(deps, io);
|
|
13905
15140
|
return 0;
|
|
13906
15141
|
}
|
|
13907
15142
|
function printLoginHelp(io) {
|
|
@@ -13925,14 +15160,19 @@ function printLoginHelp(io) {
|
|
|
13925
15160
|
io.out(" 0 signed in / session stored");
|
|
13926
15161
|
io.out(" 1 login failed (network, browser, or gateway error)");
|
|
13927
15162
|
}
|
|
13928
|
-
function
|
|
15163
|
+
async function agreementNoticeSafely(deps, io) {
|
|
15164
|
+
try {
|
|
15165
|
+
await deps.agreementNotice?.(io);
|
|
15166
|
+
} catch {}
|
|
15167
|
+
}
|
|
15168
|
+
function describe24(e) {
|
|
13929
15169
|
return e instanceof Error ? e.message : String(e);
|
|
13930
15170
|
}
|
|
13931
15171
|
|
|
13932
15172
|
// src/commands/logout.ts
|
|
13933
|
-
var
|
|
15173
|
+
var REAL_DEPS3 = { revoke: revokeGatewaySession };
|
|
13934
15174
|
var logoutCommand = makeLogoutCommand();
|
|
13935
|
-
function makeLogoutCommand(deps =
|
|
15175
|
+
function makeLogoutCommand(deps = REAL_DEPS3) {
|
|
13936
15176
|
return {
|
|
13937
15177
|
name: "logout",
|
|
13938
15178
|
summary: "revoke the session server-side and clear it locally",
|
|
@@ -13962,14 +15202,14 @@ async function runLogout(args, io, deps) {
|
|
|
13962
15202
|
});
|
|
13963
15203
|
io.out("Server-side session revoked.");
|
|
13964
15204
|
} catch (e) {
|
|
13965
|
-
io.err(`warning: could not revoke the session server-side (${
|
|
15205
|
+
io.err(`warning: could not revoke the session server-side (${describe25(e)}) — clearing the local session anyway. Any in-flight access token expires within 15 minutes.`);
|
|
13966
15206
|
}
|
|
13967
15207
|
}
|
|
13968
15208
|
const had = await clearSession(cfg.sessionPath);
|
|
13969
15209
|
io.out(had ? `Logged out. Session cleared at ${cfg.sessionPath}` : "Already logged out.");
|
|
13970
15210
|
return 0;
|
|
13971
15211
|
} catch (e) {
|
|
13972
|
-
io.err(`launchpad logout failed: ${
|
|
15212
|
+
io.err(`launchpad logout failed: ${describe25(e)}`);
|
|
13973
15213
|
return 1;
|
|
13974
15214
|
}
|
|
13975
15215
|
}
|
|
@@ -13989,7 +15229,7 @@ function printLogoutHelp(io) {
|
|
|
13989
15229
|
io.out(" 0 logged out (or already logged out)");
|
|
13990
15230
|
io.out(" 1 could not clear the local session (file IO / config error)");
|
|
13991
15231
|
}
|
|
13992
|
-
function
|
|
15232
|
+
function describe25(e) {
|
|
13993
15233
|
return e instanceof Error ? e.message : String(e);
|
|
13994
15234
|
}
|
|
13995
15235
|
|
|
@@ -14064,7 +15304,7 @@ async function runLogs(args, io) {
|
|
|
14064
15304
|
io.err(`launchpad logs: ${e.message}`);
|
|
14065
15305
|
return 1;
|
|
14066
15306
|
}
|
|
14067
|
-
io.err(`launchpad logs failed: ${
|
|
15307
|
+
io.err(`launchpad logs failed: ${describe26(e)}`);
|
|
14068
15308
|
return 1;
|
|
14069
15309
|
}
|
|
14070
15310
|
}
|
|
@@ -14153,7 +15393,7 @@ function formatRelative2(iso) {
|
|
|
14153
15393
|
return `${hr}h ago`;
|
|
14154
15394
|
return `${Math.floor(hr / 24)}d ago`;
|
|
14155
15395
|
}
|
|
14156
|
-
function
|
|
15396
|
+
function describe26(e) {
|
|
14157
15397
|
return e instanceof Error ? e.message : String(e);
|
|
14158
15398
|
}
|
|
14159
15399
|
|
|
@@ -14202,7 +15442,7 @@ async function runMerge(args, io) {
|
|
|
14202
15442
|
try {
|
|
14203
15443
|
body = await res.json();
|
|
14204
15444
|
} catch (e) {
|
|
14205
|
-
io.err(`launchpad merge: bot returned 2xx with malformed body: ${
|
|
15445
|
+
io.err(`launchpad merge: bot returned 2xx with malformed body: ${describe27(e)}`);
|
|
14206
15446
|
return 1;
|
|
14207
15447
|
}
|
|
14208
15448
|
io.out("");
|
|
@@ -14242,7 +15482,7 @@ async function runMerge(args, io) {
|
|
|
14242
15482
|
io.err(`launchpad merge: ${e.message}`);
|
|
14243
15483
|
return 1;
|
|
14244
15484
|
}
|
|
14245
|
-
io.err(`launchpad merge failed: ${
|
|
15485
|
+
io.err(`launchpad merge failed: ${describe27(e)}`);
|
|
14246
15486
|
return 1;
|
|
14247
15487
|
}
|
|
14248
15488
|
}
|
|
@@ -14341,12 +15581,12 @@ function renderBotError(status, env, io, prNumber = null) {
|
|
|
14341
15581
|
io.err(`launchpad merge: bot returned ${status} ${code}${detail !== undefined ? `: ${detail}` : ""}`);
|
|
14342
15582
|
}
|
|
14343
15583
|
}
|
|
14344
|
-
function
|
|
15584
|
+
function describe27(e) {
|
|
14345
15585
|
return e instanceof Error ? e.message : String(e);
|
|
14346
15586
|
}
|
|
14347
15587
|
|
|
14348
15588
|
// src/commands/plan.ts
|
|
14349
|
-
import { resolve as
|
|
15589
|
+
import { resolve as resolve13 } from "node:path";
|
|
14350
15590
|
|
|
14351
15591
|
// src/manifest/container-runtime-warnings.ts
|
|
14352
15592
|
var CONTAINER_RUNTIME_GATE_WARNING = "Container apps are gated by the platform runtime switch; `launchpad deploy` may return " + "503 container_runtime_off until the platform team enables your app. See docs/concepts/containers.md.";
|
|
@@ -14373,7 +15613,7 @@ async function runPlan(args, io) {
|
|
|
14373
15613
|
io.err("Usage: launchpad plan [--file <path>] [--json]");
|
|
14374
15614
|
return 64;
|
|
14375
15615
|
}
|
|
14376
|
-
const manifestPath =
|
|
15616
|
+
const manifestPath = resolve13(process.cwd(), flags.file ?? "launchpad.yaml");
|
|
14377
15617
|
const result = loadManifest(manifestPath);
|
|
14378
15618
|
if (result.kind === "ok") {
|
|
14379
15619
|
const unsupported2 = rejectUnsupportedCliRuntime({
|
|
@@ -14575,7 +15815,7 @@ import { stdin as input2, stdout as output2 } from "node:process";
|
|
|
14575
15815
|
var destroyCommand = {
|
|
14576
15816
|
name: "destroy",
|
|
14577
15817
|
summary: "tear down a Launchpad app (owner-only, destructive)",
|
|
14578
|
-
run: (args, io) => runDestroy(args, io,
|
|
15818
|
+
run: (args, io) => runDestroy(args, io, defaultPrompt5, defaultIsTty)
|
|
14579
15819
|
};
|
|
14580
15820
|
var SLUG_RE11 = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
|
|
14581
15821
|
var SLUG_MIN_LENGTH = 3;
|
|
@@ -14632,7 +15872,7 @@ async function runDestroy(args, io, prompt, isTty) {
|
|
|
14632
15872
|
io.err(`launchpad destroy: ${e.message}`);
|
|
14633
15873
|
return 1;
|
|
14634
15874
|
}
|
|
14635
|
-
io.err(`launchpad destroy failed: ${
|
|
15875
|
+
io.err(`launchpad destroy failed: ${describe28(e)}`);
|
|
14636
15876
|
return 1;
|
|
14637
15877
|
}
|
|
14638
15878
|
}
|
|
@@ -14806,7 +16046,7 @@ function renderBotError2(status, env, slug, io) {
|
|
|
14806
16046
|
io.err(`launchpad destroy: bot returned HTTP ${status} (error=${errorCode}): ${message}`);
|
|
14807
16047
|
}
|
|
14808
16048
|
}
|
|
14809
|
-
async function
|
|
16049
|
+
async function defaultPrompt5(question) {
|
|
14810
16050
|
const rl = createInterface3({ input: input2, output: output2 });
|
|
14811
16051
|
try {
|
|
14812
16052
|
return await rl.question(question);
|
|
@@ -14832,12 +16072,12 @@ function printUsage5(io) {
|
|
|
14832
16072
|
].join(`
|
|
14833
16073
|
`));
|
|
14834
16074
|
}
|
|
14835
|
-
function
|
|
16075
|
+
function describe28(e) {
|
|
14836
16076
|
return e instanceof Error ? e.message : String(e);
|
|
14837
16077
|
}
|
|
14838
16078
|
|
|
14839
16079
|
// src/commands/pull.ts
|
|
14840
|
-
import { writeFileSync as
|
|
16080
|
+
import { writeFileSync as writeFileSync6 } from "node:fs";
|
|
14841
16081
|
import { stringify as stringifyYaml } from "yaml";
|
|
14842
16082
|
|
|
14843
16083
|
// src/deploy/manifest-status.ts
|
|
@@ -14850,7 +16090,7 @@ async function fetchManifestStatus(cfg, slug, fetcher = fetch) {
|
|
|
14850
16090
|
import * as fs6 from "node:fs/promises";
|
|
14851
16091
|
import * as path13 from "node:path";
|
|
14852
16092
|
import { constants as fsConstants } from "node:fs";
|
|
14853
|
-
import { createHash as
|
|
16093
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
14854
16094
|
import { execFile } from "node:child_process";
|
|
14855
16095
|
var CONFLICT_REPORT = `${MARKER_DIR}/pull-conflicts.json`;
|
|
14856
16096
|
var CONFLICT_DIR = `${MARKER_DIR}/pull-conflicts`;
|
|
@@ -14988,12 +16228,12 @@ async function listFiles(root, relative6 = "") {
|
|
|
14988
16228
|
return files.sort();
|
|
14989
16229
|
}
|
|
14990
16230
|
function gitOutput(cwd, args) {
|
|
14991
|
-
return new Promise((
|
|
16231
|
+
return new Promise((resolve15, reject) => {
|
|
14992
16232
|
execFile("git", [...args], { cwd, encoding: "utf8" }, (error, stdout) => {
|
|
14993
16233
|
if (error !== null)
|
|
14994
16234
|
reject(error);
|
|
14995
16235
|
else
|
|
14996
|
-
|
|
16236
|
+
resolve15(stdout);
|
|
14997
16237
|
});
|
|
14998
16238
|
});
|
|
14999
16239
|
}
|
|
@@ -15085,7 +16325,7 @@ async function planPath(args, relative6, removals) {
|
|
|
15085
16325
|
}
|
|
15086
16326
|
function conflictPlan(relative6, target, local, head, upstreamDeleted, reason) {
|
|
15087
16327
|
const suffix = upstreamDeleted ? ".upstream-deleted" : ".upstream";
|
|
15088
|
-
const digest =
|
|
16328
|
+
const digest = createHash4("sha256").update(relative6).digest("hex");
|
|
15089
16329
|
return {
|
|
15090
16330
|
relative: relative6,
|
|
15091
16331
|
target,
|
|
@@ -15353,7 +16593,7 @@ async function runPull(args, io) {
|
|
|
15353
16593
|
}
|
|
15354
16594
|
const yaml = stringifyYaml(res.status);
|
|
15355
16595
|
if (parsed.out !== null) {
|
|
15356
|
-
|
|
16596
|
+
writeFileSync6(parsed.out, yaml);
|
|
15357
16597
|
io.err(`launchpad pull: wrote status (${res.role} view) to ${parsed.out}`);
|
|
15358
16598
|
} else {
|
|
15359
16599
|
io.out(yaml.replace(/\n$/, ""));
|
|
@@ -15374,7 +16614,7 @@ async function runPull(args, io) {
|
|
|
15374
16614
|
return 1;
|
|
15375
16615
|
}
|
|
15376
16616
|
if (parsed.out !== null) {
|
|
15377
|
-
|
|
16617
|
+
writeFileSync6(parsed.out, state.manifestYaml);
|
|
15378
16618
|
io.err(`launchpad pull: wrote ${state.manifestYaml.length} bytes to ${parsed.out}`);
|
|
15379
16619
|
} else {
|
|
15380
16620
|
io.out(state.manifestYaml.replace(/\n$/, ""));
|
|
@@ -15402,7 +16642,7 @@ async function runPull(args, io) {
|
|
|
15402
16642
|
io.err(`launchpad pull: ${e.message}`);
|
|
15403
16643
|
return 1;
|
|
15404
16644
|
}
|
|
15405
|
-
io.err(`launchpad pull failed: ${
|
|
16645
|
+
io.err(`launchpad pull failed: ${describe29(e)}`);
|
|
15406
16646
|
return 1;
|
|
15407
16647
|
}
|
|
15408
16648
|
}
|
|
@@ -15503,12 +16743,212 @@ function printUsage6(io) {
|
|
|
15503
16743
|
].join(`
|
|
15504
16744
|
`));
|
|
15505
16745
|
}
|
|
15506
|
-
function
|
|
16746
|
+
function describe29(e) {
|
|
15507
16747
|
return e instanceof Error ? e.message : String(e);
|
|
15508
16748
|
}
|
|
15509
16749
|
|
|
15510
|
-
// src/commands/
|
|
16750
|
+
// src/commands/disable.ts
|
|
15511
16751
|
var SLUG_RE13 = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
|
|
16752
|
+
var REASON_RE = /^[A-Za-z0-9 ._:#/-]{1,120}$/;
|
|
16753
|
+
var disableCommand = {
|
|
16754
|
+
name: "disable",
|
|
16755
|
+
summary: "switch an app off (serves a 503) without destroying it",
|
|
16756
|
+
run: (args, io) => runVerb("disable", args, io)
|
|
16757
|
+
};
|
|
16758
|
+
var enableCommand = {
|
|
16759
|
+
name: "enable",
|
|
16760
|
+
summary: "switch a disabled app back on",
|
|
16761
|
+
run: (args, io) => runVerb("enable", args, io)
|
|
16762
|
+
};
|
|
16763
|
+
function usage(verb) {
|
|
16764
|
+
return verb === "disable" ? "usage: launchpad disable <slug> --reason <ticket> | launchpad disable <slug> --status" : "usage: launchpad enable <slug> --reason <ticket>";
|
|
16765
|
+
}
|
|
16766
|
+
async function runVerb(verb, args, io) {
|
|
16767
|
+
const parsed = parseAppDisableArgs(verb, args);
|
|
16768
|
+
if (parsed === "help") {
|
|
16769
|
+
printHelp4(verb, io);
|
|
16770
|
+
return 0;
|
|
16771
|
+
}
|
|
16772
|
+
if (typeof parsed === "string") {
|
|
16773
|
+
io.err(`launchpad ${verb}: ${parsed}`);
|
|
16774
|
+
io.err("");
|
|
16775
|
+
io.err(usage(verb));
|
|
16776
|
+
return 64;
|
|
16777
|
+
}
|
|
16778
|
+
return runAppDisable(parsed, io);
|
|
16779
|
+
}
|
|
16780
|
+
function parseAppDisableArgs(verb, args) {
|
|
16781
|
+
let slug = null;
|
|
16782
|
+
let reason = null;
|
|
16783
|
+
let status = false;
|
|
16784
|
+
for (let i = 0;i < args.length; i++) {
|
|
16785
|
+
const a = args[i] ?? "";
|
|
16786
|
+
if (a === "--help" || a === "-h")
|
|
16787
|
+
return "help";
|
|
16788
|
+
if (a === "--status" && verb === "disable") {
|
|
16789
|
+
status = true;
|
|
16790
|
+
continue;
|
|
16791
|
+
}
|
|
16792
|
+
if (a === "--reason") {
|
|
16793
|
+
const v = args[i + 1];
|
|
16794
|
+
if (v === undefined)
|
|
16795
|
+
return "--reason needs a value";
|
|
16796
|
+
reason = v;
|
|
16797
|
+
i++;
|
|
16798
|
+
continue;
|
|
16799
|
+
}
|
|
16800
|
+
if (a.startsWith("--reason=")) {
|
|
16801
|
+
reason = a.slice("--reason=".length);
|
|
16802
|
+
continue;
|
|
16803
|
+
}
|
|
16804
|
+
if (a.startsWith("-"))
|
|
16805
|
+
return `unknown flag ${a}`;
|
|
16806
|
+
if (slug !== null)
|
|
16807
|
+
return `unexpected argument ${a}`;
|
|
16808
|
+
slug = a;
|
|
16809
|
+
}
|
|
16810
|
+
if (slug === null)
|
|
16811
|
+
return "an app slug is required";
|
|
16812
|
+
if (!SLUG_RE13.test(slug))
|
|
16813
|
+
return `invalid slug "${slug}"`;
|
|
16814
|
+
if (status) {
|
|
16815
|
+
if (reason !== null)
|
|
16816
|
+
return "--status takes no --reason";
|
|
16817
|
+
return { verb, slug, reason: null, status: true };
|
|
16818
|
+
}
|
|
16819
|
+
if (reason === null)
|
|
16820
|
+
return "--reason <ticket> is required (for example --reason INC-123)";
|
|
16821
|
+
reason = reason.trim();
|
|
16822
|
+
if (!REASON_RE.test(reason)) {
|
|
16823
|
+
return "--reason must be a ticket reference: letters, digits, space and . _ : # / - (up to 120)";
|
|
16824
|
+
}
|
|
16825
|
+
return { verb, slug, reason, status: false };
|
|
16826
|
+
}
|
|
16827
|
+
async function runAppDisable(opts, io, deps = {}) {
|
|
16828
|
+
const cfg = deps.config ?? loadConfig();
|
|
16829
|
+
const fetcher = deps.fetcher ?? fetch;
|
|
16830
|
+
const { verb, slug } = opts;
|
|
16831
|
+
let resp;
|
|
16832
|
+
try {
|
|
16833
|
+
resp = opts.status ? await apiJson(cfg, { method: "GET", path: `/apps/${slug}/disable` }, fetcher) : await apiJson(cfg, { method: "POST", path: `/apps/${slug}/${verb}`, jsonBody: { reason: opts.reason } }, fetcher);
|
|
16834
|
+
} catch (e) {
|
|
16835
|
+
return mapError2(e, verb, slug, io);
|
|
16836
|
+
}
|
|
16837
|
+
if (opts.status) {
|
|
16838
|
+
if (!resp.disabled) {
|
|
16839
|
+
io.out(`${slug} is not disabled by the runtime switch.`);
|
|
16840
|
+
io.out(" (A disable set in launchpad.yaml spec.lifecycle.disabled is not shown here.)");
|
|
16841
|
+
return 0;
|
|
16842
|
+
}
|
|
16843
|
+
io.out(`${slug} is DISABLED${describeHold(resp)}.`);
|
|
16844
|
+
warnIfNotEnforced(resp, slug, io);
|
|
16845
|
+
return 0;
|
|
16846
|
+
}
|
|
16847
|
+
if (verb === "disable") {
|
|
16848
|
+
if (resp.alreadyDisabled) {
|
|
16849
|
+
io.out(`${slug} was already disabled${describeHold(resp)}. Nothing changed.`);
|
|
16850
|
+
warnIfNotEnforced(resp, slug, io);
|
|
16851
|
+
return 0;
|
|
16852
|
+
}
|
|
16853
|
+
if (resp.upgradedToHold) {
|
|
16854
|
+
io.out(` ${slug} was disabled by an owner; it is now a platform hold that only the platform team can lift.`);
|
|
16855
|
+
}
|
|
16856
|
+
if (resp.enforced === true) {
|
|
16857
|
+
io.out(`✓ ${slug} is disabled. Visitors now get a 503 "This app is disabled" page.`);
|
|
16858
|
+
io.out(" It can take about a minute to reach every edge location. Data and DNS are kept.");
|
|
16859
|
+
} else {
|
|
16860
|
+
io.out(`✓ ${slug} is recorded as disabled.`);
|
|
16861
|
+
warnIfNotEnforced(resp, slug, io);
|
|
16862
|
+
}
|
|
16863
|
+
io.out(` To switch it back on: launchpad enable ${slug} --reason <ticket>`);
|
|
16864
|
+
return 0;
|
|
16865
|
+
}
|
|
16866
|
+
if (resp.alreadyEnabled) {
|
|
16867
|
+
io.out(`${slug} was not disabled by the runtime switch. Nothing changed.`);
|
|
16868
|
+
io.out(" If it still shows the disabled page, check spec.lifecycle.disabled in launchpad.yaml.");
|
|
16869
|
+
return 0;
|
|
16870
|
+
}
|
|
16871
|
+
io.out(`✓ ${slug} is enabled again. It can take about a minute to reach every edge location.`);
|
|
16872
|
+
return 0;
|
|
16873
|
+
}
|
|
16874
|
+
function warnIfNotEnforced(resp, slug, io) {
|
|
16875
|
+
if (resp.enforced === true)
|
|
16876
|
+
return;
|
|
16877
|
+
if (resp.fronted === "access") {
|
|
16878
|
+
io.err(`! ${slug} is not fronted by the gateway (for example auth: access). This switch does NOT stop it.`);
|
|
16879
|
+
return;
|
|
16880
|
+
}
|
|
16881
|
+
if (resp.gatewayMode === "off" || resp.gatewayMode === "report") {
|
|
16882
|
+
io.err(`! The gateway is not enforcing disables yet (mode: ${resp.gatewayMode}). ${slug} is STILL SERVING visitors.`);
|
|
16883
|
+
io.err(" Ask the Launchpad platform team to switch the gateway to enforce, or use another control.");
|
|
16884
|
+
return;
|
|
16885
|
+
}
|
|
16886
|
+
io.err(`! The bot did not confirm that the gateway enforces this. Check that ${slug} returns a 503.`);
|
|
16887
|
+
}
|
|
16888
|
+
function describeHold(resp) {
|
|
16889
|
+
if (resp.malformed)
|
|
16890
|
+
return " (record unreadable; only the platform team can enable it)";
|
|
16891
|
+
const parts = [];
|
|
16892
|
+
if (resp.actorRole === "break_glass" || resp.platformHold === true && resp.actorRole === undefined) {
|
|
16893
|
+
parts.push("by the platform team");
|
|
16894
|
+
}
|
|
16895
|
+
if (resp.actorRole === "owner")
|
|
16896
|
+
parts.push("by an owner");
|
|
16897
|
+
if (typeof resp.disabledAt === "number")
|
|
16898
|
+
parts.push(`at ${new Date(resp.disabledAt * 1000).toISOString()}`);
|
|
16899
|
+
if (typeof resp.reason === "string")
|
|
16900
|
+
parts.push(`reason ${resp.reason}`);
|
|
16901
|
+
return parts.length === 0 ? "" : ` (${parts.join(", ")})`;
|
|
16902
|
+
}
|
|
16903
|
+
function mapError2(e, verb, slug, io) {
|
|
16904
|
+
if (e instanceof UnauthenticatedError) {
|
|
16905
|
+
io.err(`✗ ${verb} ${slug}: ${e.message}`);
|
|
16906
|
+
return 3;
|
|
16907
|
+
}
|
|
16908
|
+
if (e instanceof ForbiddenError) {
|
|
16909
|
+
io.err(`✗ ${verb} ${slug}: forbidden. ${e.message}`);
|
|
16910
|
+
if (verb === "enable") {
|
|
16911
|
+
io.err(" If the platform team disabled this app, only the platform team can enable it.");
|
|
16912
|
+
} else {
|
|
16913
|
+
io.err(" Only an owner, a co-owner or the platform team can disable an app.");
|
|
16914
|
+
}
|
|
16915
|
+
return 1;
|
|
16916
|
+
}
|
|
16917
|
+
if (e instanceof NotFoundError) {
|
|
16918
|
+
io.err(`✗ ${verb} ${slug}: not found. Either there is no app '${slug}', or the`);
|
|
16919
|
+
io.err(" disable feature is not switched on yet (ask the Launchpad platform team).");
|
|
16920
|
+
return 1;
|
|
16921
|
+
}
|
|
16922
|
+
if (e instanceof TransportError) {
|
|
16923
|
+
io.err(`✗ ${verb} ${slug}: ${e.message}`);
|
|
16924
|
+
return 2;
|
|
16925
|
+
}
|
|
16926
|
+
if (e instanceof ApiError) {
|
|
16927
|
+
io.err(`✗ ${verb} ${slug}: ${e.message}`);
|
|
16928
|
+
return 1;
|
|
16929
|
+
}
|
|
16930
|
+
io.err(`✗ ${verb} ${slug} failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
16931
|
+
return 2;
|
|
16932
|
+
}
|
|
16933
|
+
function printHelp4(verb, io) {
|
|
16934
|
+
io.out(usage(verb));
|
|
16935
|
+
io.out("");
|
|
16936
|
+
if (verb === "disable") {
|
|
16937
|
+
io.out("Switch an app off without destroying it. Visitors get a 503 page; data, DNS and");
|
|
16938
|
+
io.out("the deployment are kept. Owner, co-owner or platform team only.");
|
|
16939
|
+
io.out("");
|
|
16940
|
+
io.out(" --reason <ticket> required: a ticket reference, e.g. INC-123");
|
|
16941
|
+
io.out(" --status show whether the app is disabled (any role on the app)");
|
|
16942
|
+
} else {
|
|
16943
|
+
io.out("Switch a disabled app back on. An owner can lift a disable an owner set; a");
|
|
16944
|
+
io.out("disable set by the platform team needs the platform team.");
|
|
16945
|
+
io.out("");
|
|
16946
|
+
io.out(" --reason <ticket> required: a ticket reference, e.g. INC-123");
|
|
16947
|
+
}
|
|
16948
|
+
}
|
|
16949
|
+
|
|
16950
|
+
// src/commands/watch.ts
|
|
16951
|
+
var SLUG_RE14 = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
|
|
15512
16952
|
function printUsage7(io) {
|
|
15513
16953
|
io.err("usage: launchpad watch [<slug>] [--slug <slug>] [--file <path>]");
|
|
15514
16954
|
io.err(" Watch an app provision to live in real time.");
|
|
@@ -15534,7 +16974,7 @@ function resolveWatchSlug(args, cwd, warn) {
|
|
|
15534
16974
|
if (slug === undefined) {
|
|
15535
16975
|
return { error: "no slug given and none could be inferred from the current directory" };
|
|
15536
16976
|
}
|
|
15537
|
-
if (!
|
|
16977
|
+
if (!SLUG_RE14.test(slug)) {
|
|
15538
16978
|
return { error: `invalid slug: "${slug}"` };
|
|
15539
16979
|
}
|
|
15540
16980
|
return { slug };
|
|
@@ -15561,7 +17001,7 @@ var reviewCommand = {
|
|
|
15561
17001
|
summary: "show the review state for a PR (slug-scoped)",
|
|
15562
17002
|
run: runReview
|
|
15563
17003
|
};
|
|
15564
|
-
var
|
|
17004
|
+
var SLUG_RE15 = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;
|
|
15565
17005
|
async function runReview(args, io) {
|
|
15566
17006
|
const parsed = parseArgs11(args);
|
|
15567
17007
|
if (parsed === null) {
|
|
@@ -15581,8 +17021,8 @@ async function runReview(args, io) {
|
|
|
15581
17021
|
}
|
|
15582
17022
|
slug = inferred;
|
|
15583
17023
|
}
|
|
15584
|
-
if (!
|
|
15585
|
-
io.err(`launchpad review: invalid slug "${slug}" — expected ${
|
|
17024
|
+
if (!SLUG_RE15.test(slug)) {
|
|
17025
|
+
io.err(`launchpad review: invalid slug "${slug}" — expected ${SLUG_RE15.source}`);
|
|
15586
17026
|
return 64;
|
|
15587
17027
|
}
|
|
15588
17028
|
try {
|
|
@@ -15625,7 +17065,7 @@ async function runReview(args, io) {
|
|
|
15625
17065
|
io.err(`launchpad review: ${e.message}`);
|
|
15626
17066
|
return 1;
|
|
15627
17067
|
}
|
|
15628
|
-
io.err(`launchpad review failed: ${
|
|
17068
|
+
io.err(`launchpad review failed: ${describe30(e)}`);
|
|
15629
17069
|
return 1;
|
|
15630
17070
|
}
|
|
15631
17071
|
}
|
|
@@ -15703,12 +17143,12 @@ function severityRank(s) {
|
|
|
15703
17143
|
return 3;
|
|
15704
17144
|
}
|
|
15705
17145
|
}
|
|
15706
|
-
function
|
|
17146
|
+
function describe30(e) {
|
|
15707
17147
|
return e instanceof Error ? e.message : String(e);
|
|
15708
17148
|
}
|
|
15709
17149
|
|
|
15710
17150
|
// src/deploy/rollback.ts
|
|
15711
|
-
import { existsSync as
|
|
17151
|
+
import { existsSync as existsSync14, readFileSync as readFileSync18, writeFileSync as writeFileSync7 } from "node:fs";
|
|
15712
17152
|
import { resolve as resolvePath4 } from "node:path";
|
|
15713
17153
|
import { createInterface as createInterface4 } from "node:readline/promises";
|
|
15714
17154
|
|
|
@@ -15763,7 +17203,7 @@ async function runRollback(opts, io, deps = {}) {
|
|
|
15763
17203
|
cwd: process.cwd()
|
|
15764
17204
|
});
|
|
15765
17205
|
} catch (e) {
|
|
15766
|
-
io.err(`launchpad rollback: git rev-parse failed to start: ${
|
|
17206
|
+
io.err(`launchpad rollback: git rev-parse failed to start: ${describe31(e)}`);
|
|
15767
17207
|
return 2;
|
|
15768
17208
|
}
|
|
15769
17209
|
if (revParse.exitCode !== 0) {
|
|
@@ -15778,7 +17218,7 @@ async function runRollback(opts, io, deps = {}) {
|
|
|
15778
17218
|
try {
|
|
15779
17219
|
show = await runner.run("git", ["show", `${verifiedSha}:${manifestRelpath}`], { cwd: process.cwd() });
|
|
15780
17220
|
} catch (e) {
|
|
15781
|
-
io.err(`launchpad rollback: git show failed to start: ${
|
|
17221
|
+
io.err(`launchpad rollback: git show failed to start: ${describe31(e)}`);
|
|
15782
17222
|
return 2;
|
|
15783
17223
|
}
|
|
15784
17224
|
if (show.exitCode !== 0) {
|
|
@@ -15798,7 +17238,7 @@ async function runRollback(opts, io, deps = {}) {
|
|
|
15798
17238
|
io.out(`Rollback target: ${verifiedSha.slice(0, 12)} (${manifestRelpath})`);
|
|
15799
17239
|
renderDiff(current, parsed.manifest, io);
|
|
15800
17240
|
if (!opts.yes) {
|
|
15801
|
-
const prompt = deps.prompt ??
|
|
17241
|
+
const prompt = deps.prompt ?? defaultPrompt6;
|
|
15802
17242
|
if (!process.stdin.isTTY && deps.prompt === undefined) {
|
|
15803
17243
|
io.err("launchpad rollback: refusing to rollback non-interactively without --yes.");
|
|
15804
17244
|
return 64;
|
|
@@ -15810,9 +17250,9 @@ async function runRollback(opts, io, deps = {}) {
|
|
|
15810
17250
|
}
|
|
15811
17251
|
}
|
|
15812
17252
|
try {
|
|
15813
|
-
|
|
17253
|
+
writeFileSync7(manifestPath, historicalYaml, "utf8");
|
|
15814
17254
|
} catch (e) {
|
|
15815
|
-
io.err(`launchpad rollback: failed to write ${manifestPath}: ${
|
|
17255
|
+
io.err(`launchpad rollback: failed to write ${manifestPath}: ${describe31(e)}`);
|
|
15816
17256
|
return 2;
|
|
15817
17257
|
}
|
|
15818
17258
|
io.out(`Restored ${manifestPath} from ${verifiedSha.slice(0, 12)}.`);
|
|
@@ -15833,7 +17273,7 @@ async function runRollback(opts, io, deps = {}) {
|
|
|
15833
17273
|
}, io, applyDeps);
|
|
15834
17274
|
}
|
|
15835
17275
|
function readCurrentManifest(path15) {
|
|
15836
|
-
if (!
|
|
17276
|
+
if (!existsSync14(path15))
|
|
15837
17277
|
return null;
|
|
15838
17278
|
let raw;
|
|
15839
17279
|
try {
|
|
@@ -15886,7 +17326,7 @@ function formatHostnames(hs) {
|
|
|
15886
17326
|
return hs[0];
|
|
15887
17327
|
return `[${hs.join(", ")}]`;
|
|
15888
17328
|
}
|
|
15889
|
-
async function
|
|
17329
|
+
async function defaultPrompt6(question) {
|
|
15890
17330
|
const rl = createInterface4({ input: process.stdin, output: process.stderr });
|
|
15891
17331
|
try {
|
|
15892
17332
|
return await rl.question(question);
|
|
@@ -15894,7 +17334,7 @@ async function defaultPrompt5(question) {
|
|
|
15894
17334
|
rl.close();
|
|
15895
17335
|
}
|
|
15896
17336
|
}
|
|
15897
|
-
function
|
|
17337
|
+
function describe31(e) {
|
|
15898
17338
|
return e instanceof Error ? e.message : String(e);
|
|
15899
17339
|
}
|
|
15900
17340
|
function renderManifestError4(result, io) {
|
|
@@ -16106,7 +17546,7 @@ function renderManifestError5(result, io) {
|
|
|
16106
17546
|
}
|
|
16107
17547
|
|
|
16108
17548
|
// src/secrets/set.ts
|
|
16109
|
-
import { existsSync as
|
|
17549
|
+
import { existsSync as existsSync15, readFileSync as readFileSync19 } from "node:fs";
|
|
16110
17550
|
import { resolve as resolvePath6 } from "node:path";
|
|
16111
17551
|
import { parse as parseYaml9 } from "yaml";
|
|
16112
17552
|
var CELL_LABEL2 = {
|
|
@@ -16116,7 +17556,7 @@ var CELL_LABEL2 = {
|
|
|
16116
17556
|
};
|
|
16117
17557
|
function loadSet(fleetFile, setName, io) {
|
|
16118
17558
|
const path15 = resolvePath6(process.cwd(), fleetFile ?? "fleet-secret-sets.yaml");
|
|
16119
|
-
if (!
|
|
17559
|
+
if (!existsSync15(path15)) {
|
|
16120
17560
|
io.err(`✗ ${path15}`);
|
|
16121
17561
|
io.err(" fleet-secret-sets.yaml not found. Run from the platform repo root or pass --fleet-file.");
|
|
16122
17562
|
return 2;
|
|
@@ -16212,7 +17652,7 @@ async function runSecretsPushSet(opts, io, deps = {}) {
|
|
|
16212
17652
|
if (typeof set === "number")
|
|
16213
17653
|
return set;
|
|
16214
17654
|
const envPath = resolvePath6(process.cwd(), opts.env ?? ".env");
|
|
16215
|
-
if (!
|
|
17655
|
+
if (!existsSync15(envPath)) {
|
|
16216
17656
|
io.err(`launchpad secrets push --set: ${envPath} not found.`);
|
|
16217
17657
|
io.err(` Create a .env carrying the set's secrets: ${set.secrets.join(", ")}`);
|
|
16218
17658
|
return 2;
|
|
@@ -16363,8 +17803,8 @@ function setPushExit(e) {
|
|
|
16363
17803
|
}
|
|
16364
17804
|
|
|
16365
17805
|
// src/commands/secrets-template.ts
|
|
16366
|
-
import { existsSync as
|
|
16367
|
-
import { resolve as
|
|
17806
|
+
import { existsSync as existsSync16, writeFileSync as writeFileSync8 } from "node:fs";
|
|
17807
|
+
import { resolve as resolve15 } from "node:path";
|
|
16368
17808
|
async function runSecretsTemplate(args, io) {
|
|
16369
17809
|
const flags = parseFlags4(args);
|
|
16370
17810
|
if (flags.kind === "usage-error") {
|
|
@@ -16372,7 +17812,7 @@ async function runSecretsTemplate(args, io) {
|
|
|
16372
17812
|
io.err("Usage: launchpad secrets template [--file <path>] [--out <path>] " + "[--stdout] [--force] [--include-platform-managed]");
|
|
16373
17813
|
return 64;
|
|
16374
17814
|
}
|
|
16375
|
-
const manifestPath =
|
|
17815
|
+
const manifestPath = resolve15(process.cwd(), flags.file ?? "launchpad.yaml");
|
|
16376
17816
|
const renderResult = renderManifest(loadManifestAnyVersion(manifestPath), io);
|
|
16377
17817
|
if (renderResult.kind !== "ok") {
|
|
16378
17818
|
return renderResult.code;
|
|
@@ -16386,14 +17826,14 @@ async function runSecretsTemplate(args, io) {
|
|
|
16386
17826
|
}
|
|
16387
17827
|
return 0;
|
|
16388
17828
|
}
|
|
16389
|
-
const outPath =
|
|
16390
|
-
if (
|
|
17829
|
+
const outPath = resolve15(process.cwd(), flags.out);
|
|
17830
|
+
if (existsSync16(outPath) && !flags.force) {
|
|
16391
17831
|
io.err(`launchpad secrets template: ${outPath} already exists`);
|
|
16392
17832
|
io.err("Pass --force to overwrite, or --stdout to print without writing.");
|
|
16393
17833
|
return 64;
|
|
16394
17834
|
}
|
|
16395
17835
|
try {
|
|
16396
|
-
|
|
17836
|
+
writeFileSync8(outPath, body, { encoding: "utf8" });
|
|
16397
17837
|
} catch (err) {
|
|
16398
17838
|
const e = err;
|
|
16399
17839
|
io.err(`launchpad secrets template: failed to write ${outPath}`);
|
|
@@ -16527,7 +17967,7 @@ var secretsCommand = {
|
|
|
16527
17967
|
async function runSecrets(args, io) {
|
|
16528
17968
|
const sub = args[0];
|
|
16529
17969
|
if (sub === undefined || sub === "--help" || sub === "-h") {
|
|
16530
|
-
|
|
17970
|
+
printHelp5(io);
|
|
16531
17971
|
return 0;
|
|
16532
17972
|
}
|
|
16533
17973
|
if (sub === "template") {
|
|
@@ -16670,7 +18110,7 @@ function parseStatusArgs(args) {
|
|
|
16670
18110
|
}
|
|
16671
18111
|
return { file, slug };
|
|
16672
18112
|
}
|
|
16673
|
-
function
|
|
18113
|
+
function printHelp5(io) {
|
|
16674
18114
|
io.out("Usage: launchpad secrets <subcommand> [options]");
|
|
16675
18115
|
io.out("");
|
|
16676
18116
|
io.out("Subcommands:");
|
|
@@ -16688,16 +18128,16 @@ function printHelp3(io) {
|
|
|
16688
18128
|
|
|
16689
18129
|
// src/commands/skills.ts
|
|
16690
18130
|
import { fileURLToPath } from "node:url";
|
|
16691
|
-
import { dirname as
|
|
16692
|
-
import { promises as fs7, existsSync as
|
|
18131
|
+
import { dirname as dirname11, join as join17, resolve as resolve16 } from "node:path";
|
|
18132
|
+
import { promises as fs7, existsSync as existsSync17 } from "node:fs";
|
|
16693
18133
|
|
|
16694
18134
|
// src/skills-bundle.ts
|
|
16695
18135
|
import { homedir as homedir2 } from "node:os";
|
|
16696
|
-
import { join as
|
|
18136
|
+
import { join as join16 } from "node:path";
|
|
16697
18137
|
import { readFileSync as readFileSync20, readdirSync as readdirSync3 } from "node:fs";
|
|
16698
18138
|
var SKILL_PREFIX = "launchpad-";
|
|
16699
18139
|
function skillsTargetDir() {
|
|
16700
|
-
return process.env.LAUNCHPAD_SKILLS_TARGET_DIR ??
|
|
18140
|
+
return process.env.LAUNCHPAD_SKILLS_TARGET_DIR ?? join16(homedir2(), ".claude", "skills");
|
|
16701
18141
|
}
|
|
16702
18142
|
function readInstalledSkills() {
|
|
16703
18143
|
try {
|
|
@@ -16707,7 +18147,7 @@ function readInstalledSkills() {
|
|
|
16707
18147
|
return { present: false, version: null };
|
|
16708
18148
|
return {
|
|
16709
18149
|
present: true,
|
|
16710
|
-
version: readSkillVersion(
|
|
18150
|
+
version: readSkillVersion(join16(dir, bundle.name, "SKILL.md"))
|
|
16711
18151
|
};
|
|
16712
18152
|
} catch {
|
|
16713
18153
|
return { present: false, version: null };
|
|
@@ -16752,7 +18192,7 @@ var skillsCommand = {
|
|
|
16752
18192
|
async function runSkills(args, io) {
|
|
16753
18193
|
const action = args[0];
|
|
16754
18194
|
if (action === undefined || action === "--help" || action === "-h") {
|
|
16755
|
-
|
|
18195
|
+
printHelp6(io);
|
|
16756
18196
|
return action === undefined ? 64 : 0;
|
|
16757
18197
|
}
|
|
16758
18198
|
try {
|
|
@@ -16767,15 +18207,15 @@ async function runSkills(args, io) {
|
|
|
16767
18207
|
default:
|
|
16768
18208
|
io.err(`launchpad skills: unknown action "${action}"`);
|
|
16769
18209
|
io.err("");
|
|
16770
|
-
|
|
18210
|
+
printHelp6(io);
|
|
16771
18211
|
return 64;
|
|
16772
18212
|
}
|
|
16773
18213
|
} catch (e) {
|
|
16774
|
-
io.err(`launchpad skills ${action}: ${
|
|
18214
|
+
io.err(`launchpad skills ${action}: ${describe32(e)}`);
|
|
16775
18215
|
return 1;
|
|
16776
18216
|
}
|
|
16777
18217
|
}
|
|
16778
|
-
function
|
|
18218
|
+
function printHelp6(io) {
|
|
16779
18219
|
io.out("launchpad skills — manage the Launchpad Claude Code slash-command bundle");
|
|
16780
18220
|
io.out("");
|
|
16781
18221
|
io.out("Usage:");
|
|
@@ -16794,13 +18234,13 @@ function resolveInstallEnv() {
|
|
|
16794
18234
|
return { bundleDir, userSkillsDir };
|
|
16795
18235
|
}
|
|
16796
18236
|
function defaultBundleDir() {
|
|
16797
|
-
const here =
|
|
18237
|
+
const here = dirname11(fileURLToPath(import.meta.url));
|
|
16798
18238
|
const candidates = [
|
|
16799
|
-
|
|
16800
|
-
|
|
18239
|
+
resolve16(here, "..", "skills"),
|
|
18240
|
+
resolve16(here, "..", "..", "skills")
|
|
16801
18241
|
];
|
|
16802
18242
|
for (const c of candidates) {
|
|
16803
|
-
if (
|
|
18243
|
+
if (existsSync17(join17(c, "launchpad-onboard", "SKILL.md"))) {
|
|
16804
18244
|
return c;
|
|
16805
18245
|
}
|
|
16806
18246
|
}
|
|
@@ -16821,12 +18261,12 @@ async function doInstall(io) {
|
|
|
16821
18261
|
}
|
|
16822
18262
|
let installed = 0;
|
|
16823
18263
|
for (const skill of BUNDLED_SKILLS) {
|
|
16824
|
-
const src =
|
|
18264
|
+
const src = join17(env.bundleDir, skill);
|
|
16825
18265
|
if (!await isDir(src)) {
|
|
16826
18266
|
io.err(`launchpad skills install: bundled skill "${skill}" missing from ${env.bundleDir} — package is incomplete.`);
|
|
16827
18267
|
return 1;
|
|
16828
18268
|
}
|
|
16829
|
-
const dest =
|
|
18269
|
+
const dest = join17(env.userSkillsDir, skill);
|
|
16830
18270
|
await fs7.rm(dest, { recursive: true, force: true });
|
|
16831
18271
|
await fs7.cp(src, dest, { recursive: true });
|
|
16832
18272
|
installed++;
|
|
@@ -16851,7 +18291,7 @@ async function doUninstall(io) {
|
|
|
16851
18291
|
continue;
|
|
16852
18292
|
if (!isBundleManaged(entry.name))
|
|
16853
18293
|
continue;
|
|
16854
|
-
const target =
|
|
18294
|
+
const target = join17(env.userSkillsDir, entry.name);
|
|
16855
18295
|
await fs7.rm(target, { recursive: true, force: true });
|
|
16856
18296
|
removed++;
|
|
16857
18297
|
io.out(`✗ removed ${target}`);
|
|
@@ -16874,7 +18314,7 @@ async function doList(io) {
|
|
|
16874
18314
|
}
|
|
16875
18315
|
const width = managedDirs.reduce((n, s) => Math.max(n, s.length), 0);
|
|
16876
18316
|
for (const name of managedDirs) {
|
|
16877
|
-
const skillFile =
|
|
18317
|
+
const skillFile = join17(env.userSkillsDir, name, "SKILL.md");
|
|
16878
18318
|
const version = await readVersion(skillFile);
|
|
16879
18319
|
io.out(` ${name.padEnd(width + 2)}${version ?? "(no version)"}`);
|
|
16880
18320
|
}
|
|
@@ -16901,7 +18341,7 @@ async function isDir(path15) {
|
|
|
16901
18341
|
return false;
|
|
16902
18342
|
}
|
|
16903
18343
|
}
|
|
16904
|
-
function
|
|
18344
|
+
function describe32(e) {
|
|
16905
18345
|
return e instanceof Error ? e.message : String(e);
|
|
16906
18346
|
}
|
|
16907
18347
|
|
|
@@ -16909,13 +18349,13 @@ function describe31(e) {
|
|
|
16909
18349
|
import { execFile as execFile2, spawn as spawn5 } from "node:child_process";
|
|
16910
18350
|
import { promisify } from "node:util";
|
|
16911
18351
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
16912
|
-
import { dirname as
|
|
18352
|
+
import { dirname as dirname12, resolve as resolve17, relative as relative6, isAbsolute as isAbsolute3, join as join18 } from "node:path";
|
|
16913
18353
|
import { homedir as homedir3, tmpdir } from "node:os";
|
|
16914
|
-
import { readFileSync as readFileSync21, mkdtempSync as mkdtempSync2, writeFileSync as
|
|
18354
|
+
import { readFileSync as readFileSync21, mkdtempSync as mkdtempSync2, writeFileSync as writeFileSync9, rmSync as rmSync3 } from "node:fs";
|
|
16915
18355
|
|
|
16916
18356
|
// src/commands/channel-auth.ts
|
|
16917
18357
|
import { createServer as createServer2 } from "node:http";
|
|
16918
|
-
import { createHash as
|
|
18358
|
+
import { createHash as createHash5, randomBytes as randomBytes5 } from "node:crypto";
|
|
16919
18359
|
var CHANNEL_BASE = "https://get.launchpad.m-kopa.us";
|
|
16920
18360
|
var CLI_AUTH_URL = `${CHANNEL_BASE}/__cli_auth`;
|
|
16921
18361
|
var CLI_TOKEN_URL = `${CHANNEL_BASE}/__cli_token`;
|
|
@@ -16926,7 +18366,7 @@ function base64url(b) {
|
|
|
16926
18366
|
}
|
|
16927
18367
|
function pkcePair() {
|
|
16928
18368
|
const verifier = base64url(randomBytes5(32));
|
|
16929
|
-
const challenge = base64url(
|
|
18369
|
+
const challenge = base64url(createHash5("sha256").update(verifier).digest());
|
|
16930
18370
|
return { verifier, challenge };
|
|
16931
18371
|
}
|
|
16932
18372
|
async function startLoopback(state, timeoutMs) {
|
|
@@ -16954,9 +18394,9 @@ async function startLoopback(state, timeoutMs) {
|
|
|
16954
18394
|
resolveCode(code);
|
|
16955
18395
|
}
|
|
16956
18396
|
});
|
|
16957
|
-
const bound = await new Promise((
|
|
16958
|
-
server.once("error", () =>
|
|
16959
|
-
server.listen(0, "127.0.0.1", () =>
|
|
18397
|
+
const bound = await new Promise((resolve17) => {
|
|
18398
|
+
server.once("error", () => resolve17(false));
|
|
18399
|
+
server.listen(0, "127.0.0.1", () => resolve17(true));
|
|
16960
18400
|
});
|
|
16961
18401
|
if (!bound)
|
|
16962
18402
|
return null;
|
|
@@ -17032,7 +18472,7 @@ var PKG = "@m-kopa/launchpad-cli";
|
|
|
17032
18472
|
var REGISTRY = "https://registry.npmjs.org";
|
|
17033
18473
|
var CHANNEL_VERSION_URL = "https://get.launchpad.m-kopa.us/version.json";
|
|
17034
18474
|
var CHANNEL_INSTALL_URL = "https://get.launchpad.m-kopa.us";
|
|
17035
|
-
var CHANNEL_MARKER =
|
|
18475
|
+
var CHANNEL_MARKER = join18(homedir3(), ".launchpad", "channel");
|
|
17036
18476
|
var EXIT_UPDATE_AVAILABLE = 10;
|
|
17037
18477
|
var UPGRADE_ARGS = {
|
|
17038
18478
|
npm: ["install", "-g", `${PKG}@latest`],
|
|
@@ -17161,10 +18601,10 @@ async function openSystemBrowser(url) {
|
|
|
17161
18601
|
await execFileAsync(opener, [url]);
|
|
17162
18602
|
}
|
|
17163
18603
|
async function runInstallerScript(script) {
|
|
17164
|
-
const dir = mkdtempSync2(
|
|
17165
|
-
const file =
|
|
18604
|
+
const dir = mkdtempSync2(join18(tmpdir(), "launchpad-update-"));
|
|
18605
|
+
const file = join18(dir, "install.sh");
|
|
17166
18606
|
try {
|
|
17167
|
-
|
|
18607
|
+
writeFileSync9(file, script, { mode: 448 });
|
|
17168
18608
|
return await new Promise((resolvePromise) => {
|
|
17169
18609
|
const child = spawn5("bash", [file], { stdio: "inherit" });
|
|
17170
18610
|
child.on("error", () => resolvePromise(127));
|
|
@@ -17249,7 +18689,7 @@ function errStderr(e) {
|
|
|
17249
18689
|
return "";
|
|
17250
18690
|
}
|
|
17251
18691
|
async function detectPackageManager2() {
|
|
17252
|
-
const pkgRoot =
|
|
18692
|
+
const pkgRoot = resolve17(dirname12(fileURLToPath2(import.meta.url)), "..", "..");
|
|
17253
18693
|
const candidates = [];
|
|
17254
18694
|
const npmRoot = await pmRoot("npm");
|
|
17255
18695
|
if (npmRoot !== null)
|
|
@@ -17257,7 +18697,7 @@ async function detectPackageManager2() {
|
|
|
17257
18697
|
const pnpmRoot = await pmRoot("pnpm");
|
|
17258
18698
|
if (pnpmRoot !== null)
|
|
17259
18699
|
candidates.push(["pnpm", pnpmRoot]);
|
|
17260
|
-
candidates.push(["bun",
|
|
18700
|
+
candidates.push(["bun", resolve17(homedir3(), ".bun/install/global/node_modules")]);
|
|
17261
18701
|
const matches = candidates.filter(([, root]) => pathContains(root, pkgRoot));
|
|
17262
18702
|
return matches.length === 1 ? matches[0][0] : null;
|
|
17263
18703
|
}
|
|
@@ -17289,11 +18729,11 @@ async function runUpdate(args, io, deps) {
|
|
|
17289
18729
|
if (parsed.error !== null) {
|
|
17290
18730
|
io.err(`launchpad update: ${parsed.error}`);
|
|
17291
18731
|
io.err("");
|
|
17292
|
-
|
|
18732
|
+
printHelp7(io);
|
|
17293
18733
|
return 64;
|
|
17294
18734
|
}
|
|
17295
18735
|
if (parsed.help) {
|
|
17296
|
-
|
|
18736
|
+
printHelp7(io);
|
|
17297
18737
|
return 0;
|
|
17298
18738
|
}
|
|
17299
18739
|
const latest = await deps.fetchLatestVersion();
|
|
@@ -17370,7 +18810,7 @@ async function runUpdate(args, io, deps) {
|
|
|
17370
18810
|
await syncSkillsAfterUpgrade(io, deps);
|
|
17371
18811
|
return 0;
|
|
17372
18812
|
}
|
|
17373
|
-
function
|
|
18813
|
+
function printHelp7(io) {
|
|
17374
18814
|
io.out("launchpad update — self-update the launchpad CLI.");
|
|
17375
18815
|
io.out("");
|
|
17376
18816
|
io.out("Usage:");
|
|
@@ -17394,8 +18834,83 @@ function printHelp5(io) {
|
|
|
17394
18834
|
}
|
|
17395
18835
|
|
|
17396
18836
|
// src/commands/validate.ts
|
|
17397
|
-
import { existsSync as
|
|
17398
|
-
import { dirname as
|
|
18837
|
+
import { existsSync as existsSync18, readFileSync as readFileSync23, readdirSync as readdirSync4, statSync as statSync3 } from "node:fs";
|
|
18838
|
+
import { dirname as dirname13, resolve as resolve18 } from "node:path";
|
|
18839
|
+
|
|
18840
|
+
// src/commands/app-lints.ts
|
|
18841
|
+
import { readFileSync as readFileSync22, statSync as statSync2 } from "node:fs";
|
|
18842
|
+
import { join as join19 } from "node:path";
|
|
18843
|
+
var MAX_READ_BYTES = 512000;
|
|
18844
|
+
function cleanRoot(rootDir) {
|
|
18845
|
+
if (rootDir === undefined)
|
|
18846
|
+
return;
|
|
18847
|
+
const r = rootDir.replace(/^\.\/?/, "").replace(/\/+$/, "");
|
|
18848
|
+
return r === "" ? undefined : r;
|
|
18849
|
+
}
|
|
18850
|
+
function runAppLints(dir, rootDir) {
|
|
18851
|
+
const root = cleanRoot(rootDir);
|
|
18852
|
+
const files = {};
|
|
18853
|
+
let skipped;
|
|
18854
|
+
try {
|
|
18855
|
+
for (const rel of walkCwd(dir).files) {
|
|
18856
|
+
const inRoot = root === undefined ? rel : rel.startsWith(`${root}/`) ? rel.slice(root.length + 1) : null;
|
|
18857
|
+
if (inRoot === null || !isServerCodePath(inRoot))
|
|
18858
|
+
continue;
|
|
18859
|
+
const abs = join19(dir, rel);
|
|
18860
|
+
if (statSync2(abs).size > MAX_READ_BYTES)
|
|
18861
|
+
continue;
|
|
18862
|
+
files[rel] = readFileSync22(abs, "utf8");
|
|
18863
|
+
}
|
|
18864
|
+
} catch (e) {
|
|
18865
|
+
skipped = e instanceof Error ? e.message : String(e);
|
|
18866
|
+
}
|
|
18867
|
+
const opts = root === undefined ? {} : { rootDir: root };
|
|
18868
|
+
return {
|
|
18869
|
+
routeAuth: lintRouteAuth(files, opts),
|
|
18870
|
+
assertion: lintAssertionVerification(files, opts),
|
|
18871
|
+
...skipped === undefined ? {} : { skipped }
|
|
18872
|
+
};
|
|
18873
|
+
}
|
|
18874
|
+
function renderAppLintsHuman(r) {
|
|
18875
|
+
const out = [];
|
|
18876
|
+
if (r.skipped !== undefined) {
|
|
18877
|
+
out.push(`⚠ app lints: skipped (${r.skipped})`);
|
|
18878
|
+
return out;
|
|
18879
|
+
}
|
|
18880
|
+
out.push(` app lints: ${r.routeAuth.serverFiles} server file(s), ${r.routeAuth.writeRoutes} write route(s), identity assertion: ${r.assertion.status}`);
|
|
18881
|
+
for (const f of r.routeAuth.findings) {
|
|
18882
|
+
out.push(`⚠ app lint [${f.severity}] route-without-auth: ${f.path} (${f.methods.join(", ")}; ${f.routes} route(s)) has no identity check in reach`);
|
|
18883
|
+
}
|
|
18884
|
+
for (const f of r.assertion.findings) {
|
|
18885
|
+
const extra = f.maxAgeSeconds === undefined ? "" : ` (max-age ${f.maxAgeSeconds}s)`;
|
|
18886
|
+
out.push(`⚠ app lint [${f.severity}] ${f.rule}: ${f.path}${extra}`);
|
|
18887
|
+
}
|
|
18888
|
+
if (r.routeAuth.findings.length + r.assertion.findings.length > 0) {
|
|
18889
|
+
out.push(" Report only: these do not fail validate or deploy today.");
|
|
18890
|
+
out.push(" Fix: verify X-Launchpad-User-Assertion with @m-kopa/platform-auth in a middleware around every route,");
|
|
18891
|
+
out.push(" and check the caller's role on every write route. See the launchpad-identity skill.");
|
|
18892
|
+
}
|
|
18893
|
+
return out;
|
|
18894
|
+
}
|
|
18895
|
+
function appLintsJson(r) {
|
|
18896
|
+
return {
|
|
18897
|
+
reportOnly: true,
|
|
18898
|
+
...r.skipped === undefined ? {} : { skipped: r.skipped },
|
|
18899
|
+
routeAuth: {
|
|
18900
|
+
serverFiles: r.routeAuth.serverFiles,
|
|
18901
|
+
writeRoutes: r.routeAuth.writeRoutes,
|
|
18902
|
+
findings: r.routeAuth.findings
|
|
18903
|
+
},
|
|
18904
|
+
assertion: {
|
|
18905
|
+
status: r.assertion.status,
|
|
18906
|
+
readers: r.assertion.readers,
|
|
18907
|
+
usesPlatformAuth: r.assertion.usesPlatformAuth,
|
|
18908
|
+
findings: r.assertion.findings
|
|
18909
|
+
}
|
|
18910
|
+
};
|
|
18911
|
+
}
|
|
18912
|
+
|
|
18913
|
+
// src/commands/validate.ts
|
|
17399
18914
|
var validateCommand = {
|
|
17400
18915
|
name: "validate",
|
|
17401
18916
|
summary: "validate launchpad.yaml against its v1alpha1 or v2 schema",
|
|
@@ -17405,11 +18920,11 @@ async function runValidate(args, io) {
|
|
|
17405
18920
|
const parseResult = parseArgs13(args);
|
|
17406
18921
|
if (parseResult.kind === "usage-error") {
|
|
17407
18922
|
io.err(`launchpad validate: ${parseResult.message}`);
|
|
17408
|
-
io.err("Usage: launchpad validate [--file <path>] [--strict-groups] [--json]");
|
|
18923
|
+
io.err("Usage: launchpad validate [--file <path>] [--strict-groups] [--app-lints] [--json]");
|
|
17409
18924
|
return 64;
|
|
17410
18925
|
}
|
|
17411
|
-
const { file, json, strictGroups } = parseResult;
|
|
17412
|
-
const path15 =
|
|
18926
|
+
const { file, json, strictGroups, appLints } = parseResult;
|
|
18927
|
+
const path15 = resolve18(process.cwd(), file ?? "launchpad.yaml");
|
|
17413
18928
|
const result = loadManifestAnyVersion(path15);
|
|
17414
18929
|
if (result.kind !== "ok") {
|
|
17415
18930
|
return json ? renderJsonError(result, io) : renderHumanError(result, io);
|
|
@@ -17430,11 +18945,15 @@ async function runValidate(args, io) {
|
|
|
17430
18945
|
if (serveErrors.length > 0) {
|
|
17431
18946
|
boundary.errors = [...boundary.errors, ...serveErrors];
|
|
17432
18947
|
}
|
|
18948
|
+
const lints = appLints ? runAppLints(dirname13(path15), manifestRootDir(result.manifest)) : undefined;
|
|
17433
18949
|
const groupCheck = strictGroups ? await checkGroups(allowedEntraGroups(view.access)) : { kind: "skipped" };
|
|
17434
|
-
return json ? renderJsonOk(result, groupCheck, boundary, io) : renderHumanOk(result, groupCheck, boundary, io);
|
|
18950
|
+
return json ? renderJsonOk(result, groupCheck, boundary, io, lints) : renderHumanOk(result, groupCheck, boundary, io, lints);
|
|
18951
|
+
}
|
|
18952
|
+
function manifestRootDir(manifest) {
|
|
18953
|
+
return manifest.apiVersion === "launchpad.m-kopa.us/v2" ? manifest.spec.build?.root_dir : manifest.build?.root_dir;
|
|
17435
18954
|
}
|
|
17436
18955
|
function checkBoundary(manifestPath, declared) {
|
|
17437
|
-
const dir =
|
|
18956
|
+
const dir = dirname13(manifestPath);
|
|
17438
18957
|
let files;
|
|
17439
18958
|
try {
|
|
17440
18959
|
files = walkCwd(dir).files;
|
|
@@ -17443,7 +18962,7 @@ function checkBoundary(manifestPath, declared) {
|
|
|
17443
18962
|
}
|
|
17444
18963
|
let manifestYaml;
|
|
17445
18964
|
try {
|
|
17446
|
-
manifestYaml =
|
|
18965
|
+
manifestYaml = readFileSync23(manifestPath, "utf8");
|
|
17447
18966
|
} catch {
|
|
17448
18967
|
manifestYaml = null;
|
|
17449
18968
|
}
|
|
@@ -17467,18 +18986,18 @@ function checkStaticServeDir(manifestPath, manifest) {
|
|
|
17467
18986
|
`static app destination_dir '${serveDir}' is unsafe — use a confined relative subdirectory (e.g. '${STATIC_SERVE_DIR}'). ` + `Serving '.' or an absolute/parent path would publish files outside your app's content.`
|
|
17468
18987
|
];
|
|
17469
18988
|
}
|
|
17470
|
-
const dir =
|
|
17471
|
-
const abs =
|
|
17472
|
-
if (!
|
|
18989
|
+
const dir = dirname13(manifestPath);
|
|
18990
|
+
const abs = resolve18(dir, serveDir);
|
|
18991
|
+
if (!existsSync18(abs)) {
|
|
17473
18992
|
return [
|
|
17474
18993
|
`static app serves '${serveDir}/' but that directory does not exist — nothing would be served. ` + `Create ${serveDir}/index.html (or run \`launchpad init\` to scaffold it).`
|
|
17475
18994
|
];
|
|
17476
18995
|
}
|
|
17477
18996
|
let isDir2 = false;
|
|
17478
18997
|
try {
|
|
17479
|
-
isDir2 =
|
|
18998
|
+
isDir2 = statSync3(abs).isDirectory();
|
|
17480
18999
|
} catch (e) {
|
|
17481
|
-
return [`failed to inspect static served directory '${serveDir}/': ${
|
|
19000
|
+
return [`failed to inspect static served directory '${serveDir}/': ${describe33(e)}`];
|
|
17482
19001
|
}
|
|
17483
19002
|
if (!isDir2) {
|
|
17484
19003
|
return [`static app serves '${serveDir}/' but that path is not a directory.`];
|
|
@@ -17487,14 +19006,14 @@ function checkStaticServeDir(manifestPath, manifest) {
|
|
|
17487
19006
|
try {
|
|
17488
19007
|
entries = readdirSync4(abs);
|
|
17489
19008
|
} catch (e) {
|
|
17490
|
-
return [`failed to read static served directory '${serveDir}/': ${
|
|
19009
|
+
return [`failed to read static served directory '${serveDir}/': ${describe33(e)}`];
|
|
17491
19010
|
}
|
|
17492
19011
|
if (entries.length === 0) {
|
|
17493
19012
|
return [
|
|
17494
19013
|
`static app's served directory '${serveDir}/' is empty — the deploy would serve an empty site.`
|
|
17495
19014
|
];
|
|
17496
19015
|
}
|
|
17497
|
-
if (!
|
|
19016
|
+
if (!existsSync18(resolve18(abs, "index.html"))) {
|
|
17498
19017
|
return [
|
|
17499
19018
|
`static app's served directory '${serveDir}/' has no index.html — the deploy would serve a directory with no entrypoint.`
|
|
17500
19019
|
];
|
|
@@ -17542,7 +19061,7 @@ async function checkGroup(allowedGroup, cfg) {
|
|
|
17542
19061
|
if (e instanceof ForbiddenError) {
|
|
17543
19062
|
return { kind: "forbidden", message: e.message };
|
|
17544
19063
|
}
|
|
17545
|
-
return { kind: "network", message:
|
|
19064
|
+
return { kind: "network", message: describe33(e) };
|
|
17546
19065
|
}
|
|
17547
19066
|
}
|
|
17548
19067
|
async function checkGroups(groups) {
|
|
@@ -17558,7 +19077,7 @@ async function checkGroups(groups) {
|
|
|
17558
19077
|
const ok = perGroup.every((r) => r.kind === "ok");
|
|
17559
19078
|
return ok ? { kind: "all-ok", perGroup } : { kind: "some-failed", perGroup };
|
|
17560
19079
|
}
|
|
17561
|
-
function renderHumanOk(result, group, boundary, io) {
|
|
19080
|
+
function renderHumanOk(result, group, boundary, io, lints) {
|
|
17562
19081
|
const view = manifestView(result.manifest);
|
|
17563
19082
|
io.out(`✓ ${view.name} — manifest is valid`);
|
|
17564
19083
|
io.out(` apiVersion: ${result.schema}`);
|
|
@@ -17578,6 +19097,10 @@ function renderHumanOk(result, group, boundary, io) {
|
|
|
17578
19097
|
for (const w of containerRuntimeWarnings(view)) {
|
|
17579
19098
|
io.out(`⚠ ${w}`);
|
|
17580
19099
|
}
|
|
19100
|
+
if (lints !== undefined) {
|
|
19101
|
+
for (const line of renderAppLintsHuman(lints))
|
|
19102
|
+
io.out(line);
|
|
19103
|
+
}
|
|
17581
19104
|
switch (group.kind) {
|
|
17582
19105
|
case "skipped":
|
|
17583
19106
|
return 0;
|
|
@@ -17642,7 +19165,7 @@ function renderHumanError(result, io) {
|
|
|
17642
19165
|
return 1;
|
|
17643
19166
|
}
|
|
17644
19167
|
}
|
|
17645
|
-
function renderJsonOk(result, group, boundary, io) {
|
|
19168
|
+
function renderJsonOk(result, group, boundary, io, lints) {
|
|
17646
19169
|
const view = manifestView(result.manifest);
|
|
17647
19170
|
const runtimeWarnings = containerRuntimeWarnings(view);
|
|
17648
19171
|
const base = {
|
|
@@ -17655,7 +19178,8 @@ function renderJsonOk(result, group, boundary, io) {
|
|
|
17655
19178
|
errors: boundary.errors,
|
|
17656
19179
|
warnings: boundary.warnings
|
|
17657
19180
|
},
|
|
17658
|
-
...runtimeWarnings.length > 0 ? { warnings: runtimeWarnings } : {}
|
|
19181
|
+
...runtimeWarnings.length > 0 ? { warnings: runtimeWarnings } : {},
|
|
19182
|
+
...lints === undefined ? {} : { appLints: appLintsJson(lints) }
|
|
17659
19183
|
};
|
|
17660
19184
|
if (boundary.errors.length > 0) {
|
|
17661
19185
|
io.out(JSON.stringify({ ok: false, ...base }));
|
|
@@ -17762,6 +19286,7 @@ function parseArgs13(args) {
|
|
|
17762
19286
|
let file;
|
|
17763
19287
|
let json = false;
|
|
17764
19288
|
let strictGroups = false;
|
|
19289
|
+
let appLints = false;
|
|
17765
19290
|
for (let i = 0;i < args.length; i++) {
|
|
17766
19291
|
const a = args[i];
|
|
17767
19292
|
if (a === "--json") {
|
|
@@ -17772,6 +19297,10 @@ function parseArgs13(args) {
|
|
|
17772
19297
|
strictGroups = true;
|
|
17773
19298
|
continue;
|
|
17774
19299
|
}
|
|
19300
|
+
if (a === "--app-lints") {
|
|
19301
|
+
appLints = true;
|
|
19302
|
+
continue;
|
|
19303
|
+
}
|
|
17775
19304
|
if (a === "--file") {
|
|
17776
19305
|
const next = args[i + 1];
|
|
17777
19306
|
if (next === undefined || next.startsWith("--")) {
|
|
@@ -17786,9 +19315,9 @@ function parseArgs13(args) {
|
|
|
17786
19315
|
}
|
|
17787
19316
|
return { kind: "usage-error", message: `unknown argument "${a}"` };
|
|
17788
19317
|
}
|
|
17789
|
-
return { kind: "ok", file, json, strictGroups };
|
|
19318
|
+
return { kind: "ok", file, json, strictGroups, appLints };
|
|
17790
19319
|
}
|
|
17791
|
-
function
|
|
19320
|
+
function describe33(e) {
|
|
17792
19321
|
return e instanceof Error ? e.message : String(e);
|
|
17793
19322
|
}
|
|
17794
19323
|
|
|
@@ -17841,7 +19370,7 @@ async function runWhoami(args, io) {
|
|
|
17841
19370
|
io.err(e.message);
|
|
17842
19371
|
return 1;
|
|
17843
19372
|
}
|
|
17844
|
-
io.err(`launchpad whoami failed: ${
|
|
19373
|
+
io.err(`launchpad whoami failed: ${describe34(e)}`);
|
|
17845
19374
|
return 1;
|
|
17846
19375
|
}
|
|
17847
19376
|
}
|
|
@@ -17871,11 +19400,11 @@ async function runShare(args, io) {
|
|
|
17871
19400
|
io.err(e.message);
|
|
17872
19401
|
return 1;
|
|
17873
19402
|
}
|
|
17874
|
-
io.err(`launchpad whoami --share failed: ${
|
|
19403
|
+
io.err(`launchpad whoami --share failed: ${describe34(e)}`);
|
|
17875
19404
|
return 1;
|
|
17876
19405
|
}
|
|
17877
19406
|
}
|
|
17878
|
-
function
|
|
19407
|
+
function describe34(e) {
|
|
17879
19408
|
return e instanceof Error ? e.message : String(e);
|
|
17880
19409
|
}
|
|
17881
19410
|
|
|
@@ -18041,7 +19570,7 @@ async function runEditor(action, args, io, deps) {
|
|
|
18041
19570
|
io.err(`launchpad ${verb}: no app "${slug}" — check the slug with \`launchpad apps\`.`);
|
|
18042
19571
|
return 1;
|
|
18043
19572
|
}
|
|
18044
|
-
io.err(`launchpad ${verb} failed: ${
|
|
19573
|
+
io.err(`launchpad ${verb} failed: ${describe35(e)}`);
|
|
18045
19574
|
return 1;
|
|
18046
19575
|
}
|
|
18047
19576
|
}
|
|
@@ -18075,7 +19604,7 @@ async function sendMutation(action, slug, target, version, cfg, deps) {
|
|
|
18075
19604
|
nonThrowingStatuses: [409]
|
|
18076
19605
|
});
|
|
18077
19606
|
}
|
|
18078
|
-
function
|
|
19607
|
+
function describe35(e) {
|
|
18079
19608
|
return e instanceof Error ? e.message : String(e);
|
|
18080
19609
|
}
|
|
18081
19610
|
var grantEditorCommand = makeEditorCommand("grant");
|
|
@@ -18281,7 +19810,7 @@ async function runOwner(action, args, io, deps) {
|
|
|
18281
19810
|
io.err(`launchpad ${verb}: no app "${slug}" — check the slug with \`launchpad apps\`.`);
|
|
18282
19811
|
return 1;
|
|
18283
19812
|
}
|
|
18284
|
-
io.err(`launchpad ${verb} failed: ${
|
|
19813
|
+
io.err(`launchpad ${verb} failed: ${describe36(e)}`);
|
|
18285
19814
|
return 1;
|
|
18286
19815
|
}
|
|
18287
19816
|
}
|
|
@@ -18315,21 +19844,21 @@ async function sendMutation2(action, slug, target, version, cfg, deps) {
|
|
|
18315
19844
|
nonThrowingStatuses: [409]
|
|
18316
19845
|
});
|
|
18317
19846
|
}
|
|
18318
|
-
function
|
|
19847
|
+
function describe36(e) {
|
|
18319
19848
|
return e instanceof Error ? e.message : String(e);
|
|
18320
19849
|
}
|
|
18321
19850
|
var addOwnerCommand = makeOwnerCommand("add");
|
|
18322
19851
|
var removeOwnerCommand = makeOwnerCommand("remove");
|
|
18323
19852
|
|
|
18324
19853
|
// src/commands/admin-integrations.ts
|
|
18325
|
-
import { createHash as
|
|
19854
|
+
import { createHash as createHash6, randomBytes as randomBytes6 } from "node:crypto";
|
|
18326
19855
|
import { unlink as unlink3, writeFile as writeFile5 } from "node:fs/promises";
|
|
18327
19856
|
var APPROVAL_PATH = "/admin/integrations/approval-request";
|
|
18328
19857
|
function generateIntegrationKey() {
|
|
18329
19858
|
return `lpi_${randomBytes6(32).toString("base64url")}`;
|
|
18330
19859
|
}
|
|
18331
19860
|
function integrationKeyHash(key) {
|
|
18332
|
-
return
|
|
19861
|
+
return createHash6("sha256").update(key).digest("hex");
|
|
18333
19862
|
}
|
|
18334
19863
|
async function runAdminIntegrations(args, io, config, deps) {
|
|
18335
19864
|
const parsed = parseArgs17(args);
|
|
@@ -18392,37 +19921,37 @@ async function request(body, config, io, deps) {
|
|
|
18392
19921
|
function parseArgs17(args) {
|
|
18393
19922
|
const [sub, slug, name, ...rest] = args;
|
|
18394
19923
|
if (sub !== "mint" && sub !== "revoke")
|
|
18395
|
-
return
|
|
19924
|
+
return usage2("expected `mint` or `revoke`");
|
|
18396
19925
|
if (slug === undefined || !SLUG_REGEX.test(slug))
|
|
18397
|
-
return
|
|
19926
|
+
return usage2("expected a valid app slug");
|
|
18398
19927
|
if (name === undefined || !INTEGRATION_NAME_REGEX.test(name)) {
|
|
18399
|
-
return
|
|
19928
|
+
return usage2("expected an integration name matching ^[a-z0-9][a-z0-9-]{0,62}$");
|
|
18400
19929
|
}
|
|
18401
19930
|
const flags = parseFlags5(rest);
|
|
18402
19931
|
if (typeof flags === "string")
|
|
18403
|
-
return
|
|
19932
|
+
return usage2(flags);
|
|
18404
19933
|
return sub === "revoke" ? parseRevoke(slug, name, flags) : parseMint(slug, name, flags);
|
|
18405
19934
|
}
|
|
18406
|
-
function
|
|
19935
|
+
function usage2(message) {
|
|
18407
19936
|
return { kind: "usage", message };
|
|
18408
19937
|
}
|
|
18409
19938
|
function parseRevoke(slug, name, flags) {
|
|
18410
19939
|
if (flags.out !== undefined || flags.rotate || flags.ips.length > 0)
|
|
18411
|
-
return
|
|
19940
|
+
return usage2("revoke takes only --key-sha256");
|
|
18412
19941
|
if (flags.keyHash === undefined)
|
|
18413
19942
|
return { kind: "revoke", body: { slug, name, mode: "revoke" } };
|
|
18414
19943
|
if (!INTEGRATION_KEY_SHA256_REGEX.test(flags.keyHash))
|
|
18415
|
-
return
|
|
19944
|
+
return usage2("--key-sha256 must be 64 lowercase hex characters");
|
|
18416
19945
|
return { kind: "revoke", body: { slug, name, mode: "drop-key", key_sha256: flags.keyHash } };
|
|
18417
19946
|
}
|
|
18418
19947
|
function parseMint(slug, name, flags) {
|
|
18419
19948
|
if (flags.out === undefined)
|
|
18420
|
-
return
|
|
19949
|
+
return usage2("mint requires --out <file>");
|
|
18421
19950
|
if (flags.keyHash !== undefined)
|
|
18422
|
-
return
|
|
19951
|
+
return usage2("mint does not take --key-sha256");
|
|
18423
19952
|
const badIp = flags.ips.find((ip) => !IntegrationIpSchema.safeParse(ip).success);
|
|
18424
19953
|
if (badIp !== undefined)
|
|
18425
|
-
return
|
|
19954
|
+
return usage2(`--allow-ip '${badIp}' is not an exact IPv4 or IPv6 address`);
|
|
18426
19955
|
const ips = flags.ips.length > 0 ? { allowed_ips: flags.ips } : {};
|
|
18427
19956
|
return { kind: "mint", out: flags.out, body: { slug, name, mode: flags.rotate ? "add-key" : "approve", ...ips } };
|
|
18428
19957
|
}
|
|
@@ -18454,10 +19983,97 @@ function printIntegrationsUsage(print) {
|
|
|
18454
19983
|
print(" launchpad admin integrations revoke <slug> <name> [--key-sha256 <hex>]");
|
|
18455
19984
|
}
|
|
18456
19985
|
|
|
19986
|
+
// src/commands/admin-cli-sessions.ts
|
|
19987
|
+
var REVOKE_PATH = "/admin/cli-sessions/revoke";
|
|
19988
|
+
var RECORD_PATH = "/admin/cli-sessions/revocations/";
|
|
19989
|
+
var ENTRA_OID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
19990
|
+
var REASON_RE2 = /^[A-Za-z0-9 ._:#/-]{1,120}$/;
|
|
19991
|
+
async function runAdminCliSessions(args, io, config, deps) {
|
|
19992
|
+
const parsed = parseArgs18(args);
|
|
19993
|
+
if (parsed.kind === "usage") {
|
|
19994
|
+
io.err(`launchpad admin cli-sessions: ${parsed.message}`);
|
|
19995
|
+
printCliSessionsUsage(io.err);
|
|
19996
|
+
return 64;
|
|
19997
|
+
}
|
|
19998
|
+
try {
|
|
19999
|
+
if (parsed.kind === "revoke") {
|
|
20000
|
+
const res2 = await deps.apiJson(config, {
|
|
20001
|
+
method: "POST",
|
|
20002
|
+
path: REVOKE_PATH,
|
|
20003
|
+
jsonBody: { sub: parsed.oid, reason: parsed.reason }
|
|
20004
|
+
});
|
|
20005
|
+
io.out(`CLI sessions revoked for ${parsed.oid} at ${isoTime(res2.revokedAt)}.`);
|
|
20006
|
+
io.out(`The record expires on its own at ${isoTime(res2.expiresAt)}.`);
|
|
20007
|
+
io.out(enforcementLine(res2.enforcement));
|
|
20008
|
+
return 0;
|
|
20009
|
+
}
|
|
20010
|
+
const path15 = `${RECORD_PATH}${parsed.oid}`;
|
|
20011
|
+
if (parsed.kind === "restore") {
|
|
20012
|
+
const res2 = await deps.apiJson(config, { method: "DELETE", path: path15 });
|
|
20013
|
+
io.out(`CLI session revocation lifted for ${parsed.oid}.`);
|
|
20014
|
+
io.out(enforcementLine(res2.enforcement));
|
|
20015
|
+
return 0;
|
|
20016
|
+
}
|
|
20017
|
+
const res = await deps.apiJson(config, { method: "GET", path: path15 });
|
|
20018
|
+
if (res.revoked === true) {
|
|
20019
|
+
const reason = typeof res.reason === "string" ? ` (${res.reason})` : "";
|
|
20020
|
+
io.out(`${parsed.oid}: revoked at ${isoTime(res.revokedAt)}${reason}.`);
|
|
20021
|
+
} else {
|
|
20022
|
+
io.out(`${parsed.oid}: not revoked.`);
|
|
20023
|
+
}
|
|
20024
|
+
io.out(enforcementLine(res.enforcement));
|
|
20025
|
+
return 0;
|
|
20026
|
+
} catch (error) {
|
|
20027
|
+
io.err(`launchpad admin cli-sessions ${parsed.kind}: ${error instanceof Error ? error.message : String(error)}`);
|
|
20028
|
+
return 1;
|
|
20029
|
+
}
|
|
20030
|
+
}
|
|
20031
|
+
function parseArgs18(args) {
|
|
20032
|
+
const [sub, rawOid, ...rest] = args;
|
|
20033
|
+
if (sub !== "revoke" && sub !== "status" && sub !== "restore") {
|
|
20034
|
+
return { kind: "usage", message: "expected `revoke`, `status` or `restore`" };
|
|
20035
|
+
}
|
|
20036
|
+
const oid = rawOid?.trim().toLowerCase();
|
|
20037
|
+
if (oid === undefined || !ENTRA_OID_RE.test(oid)) {
|
|
20038
|
+
return { kind: "usage", message: "expected the user's Entra object id (a GUID), not a UPN" };
|
|
20039
|
+
}
|
|
20040
|
+
if (sub !== "revoke") {
|
|
20041
|
+
return rest.length === 0 ? { kind: sub, oid } : { kind: "usage", message: `${sub} takes no options` };
|
|
20042
|
+
}
|
|
20043
|
+
if (rest.length !== 2 || rest[0] !== "--reason") {
|
|
20044
|
+
return { kind: "usage", message: "revoke requires --reason <ticket reference>" };
|
|
20045
|
+
}
|
|
20046
|
+
const reason = rest[1];
|
|
20047
|
+
if (!REASON_RE2.test(reason)) {
|
|
20048
|
+
return {
|
|
20049
|
+
kind: "usage",
|
|
20050
|
+
message: "--reason must be 1-120 characters of letters, digits, space and . _ : # / -"
|
|
20051
|
+
};
|
|
20052
|
+
}
|
|
20053
|
+
return { kind: "revoke", oid, reason };
|
|
20054
|
+
}
|
|
20055
|
+
function isoTime(value) {
|
|
20056
|
+
return typeof value === "number" && Number.isFinite(value) ? new Date(value * 1000).toISOString() : "an unknown time";
|
|
20057
|
+
}
|
|
20058
|
+
function enforcementLine(mode) {
|
|
20059
|
+
if (mode === "enforce") {
|
|
20060
|
+
return "Enforcement: on. The bot refuses this user's CLI sessions within about a minute.";
|
|
20061
|
+
}
|
|
20062
|
+
if (mode === "observe") {
|
|
20063
|
+
return "Enforcement: observe only. The bot logs this user's CLI requests but does NOT refuse them yet.";
|
|
20064
|
+
}
|
|
20065
|
+
return "Enforcement: off. The record is stored but the bot does NOT refuse this user's CLI sessions yet.";
|
|
20066
|
+
}
|
|
20067
|
+
function printCliSessionsUsage(print) {
|
|
20068
|
+
print(" launchpad admin cli-sessions revoke <entra-object-id> --reason <ticket>");
|
|
20069
|
+
print(" launchpad admin cli-sessions status <entra-object-id>");
|
|
20070
|
+
print(" launchpad admin cli-sessions restore <entra-object-id>");
|
|
20071
|
+
}
|
|
20072
|
+
|
|
18457
20073
|
// src/commands/admin.ts
|
|
18458
|
-
var
|
|
20074
|
+
var REAL_DEPS4 = { loadConfig, apiJson };
|
|
18459
20075
|
var adminCommand = makeAdminCommand();
|
|
18460
|
-
function makeAdminCommand(deps =
|
|
20076
|
+
function makeAdminCommand(deps = REAL_DEPS4) {
|
|
18461
20077
|
return {
|
|
18462
20078
|
name: "admin",
|
|
18463
20079
|
summary: "run authenticated platform-operator actions",
|
|
@@ -18484,22 +20100,25 @@ function statusPageUrl(value, allowedHost) {
|
|
|
18484
20100
|
}
|
|
18485
20101
|
async function runAdmin(args, io, deps) {
|
|
18486
20102
|
if (args.includes("--help") || args.includes("-h")) {
|
|
18487
|
-
|
|
20103
|
+
printHelp8(io);
|
|
18488
20104
|
return 0;
|
|
18489
20105
|
}
|
|
18490
20106
|
const config = deps.loadConfig();
|
|
18491
20107
|
if (args[0] === "integrations") {
|
|
18492
20108
|
return runAdminIntegrations(args.slice(1), io, config, deps);
|
|
18493
20109
|
}
|
|
20110
|
+
if (args[0] === "cli-sessions") {
|
|
20111
|
+
return runAdminCliSessions(args.slice(1), io, config, deps);
|
|
20112
|
+
}
|
|
18494
20113
|
const parsed = parseStatusRevokeArgs(args, config.statusPageHost ?? DEFAULT_STATUS_PAGE_HOST);
|
|
18495
20114
|
if (parsed.kind === "unknown") {
|
|
18496
20115
|
io.err(`launchpad admin: unknown subcommand '${parsed.subcommand}'`);
|
|
18497
|
-
|
|
20116
|
+
printHelp8(io);
|
|
18498
20117
|
return 64;
|
|
18499
20118
|
}
|
|
18500
20119
|
if (parsed.kind === "invalid") {
|
|
18501
20120
|
io.err("launchpad admin: expected `status-revoke <status-url>`");
|
|
18502
|
-
|
|
20121
|
+
printHelp8(io);
|
|
18503
20122
|
return 64;
|
|
18504
20123
|
}
|
|
18505
20124
|
return revokeStatusPage(parsed.url, config, io, deps);
|
|
@@ -18530,19 +20149,20 @@ async function revokeStatusPage(url, config, io, deps) {
|
|
|
18530
20149
|
function statusRevokeMessage(response) {
|
|
18531
20150
|
return response.revoked ? "Status page revoked." : "Status page was already absent.";
|
|
18532
20151
|
}
|
|
18533
|
-
function
|
|
20152
|
+
function printHelp8(io) {
|
|
18534
20153
|
io.out("launchpad admin - authenticated platform-operator actions.");
|
|
18535
20154
|
io.out("");
|
|
18536
20155
|
io.out("Usage:");
|
|
18537
20156
|
io.out(" launchpad admin status-revoke <status-url>");
|
|
18538
20157
|
printIntegrationsUsage(io.out);
|
|
20158
|
+
printCliSessionsUsage(io.out);
|
|
18539
20159
|
}
|
|
18540
20160
|
|
|
18541
20161
|
// src/commands/list-owners.ts
|
|
18542
20162
|
function realDeps4() {
|
|
18543
20163
|
return { loadConfig, apiJson };
|
|
18544
20164
|
}
|
|
18545
|
-
function
|
|
20165
|
+
function parseArgs19(args) {
|
|
18546
20166
|
let slug;
|
|
18547
20167
|
let json = false;
|
|
18548
20168
|
for (const a of args) {
|
|
@@ -18556,7 +20176,7 @@ function parseArgs18(args) {
|
|
|
18556
20176
|
return { slug, json };
|
|
18557
20177
|
}
|
|
18558
20178
|
async function runListOwners(args, io, deps) {
|
|
18559
|
-
const parsed =
|
|
20179
|
+
const parsed = parseArgs19(args);
|
|
18560
20180
|
if (parsed === null) {
|
|
18561
20181
|
io.err("usage: launchpad list-owners <slug> [--json]");
|
|
18562
20182
|
return 64;
|
|
@@ -18613,20 +20233,20 @@ var listOwnersCommand = makeListOwnersCommand();
|
|
|
18613
20233
|
// src/update-notifier.ts
|
|
18614
20234
|
import { spawn as spawn6 } from "node:child_process";
|
|
18615
20235
|
import { homedir as homedir4 } from "node:os";
|
|
18616
|
-
import { join as
|
|
20236
|
+
import { join as join20 } from "node:path";
|
|
18617
20237
|
import {
|
|
18618
|
-
existsSync as
|
|
18619
|
-
mkdirSync as
|
|
18620
|
-
readFileSync as
|
|
18621
|
-
writeFileSync as
|
|
20238
|
+
existsSync as existsSync19,
|
|
20239
|
+
mkdirSync as mkdirSync6,
|
|
20240
|
+
readFileSync as readFileSync24,
|
|
20241
|
+
writeFileSync as writeFileSync10
|
|
18622
20242
|
} from "node:fs";
|
|
18623
20243
|
var INTERNAL_REFRESH_VERB = "__refresh-update-cache";
|
|
18624
20244
|
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
18625
20245
|
var OPT_OUT_ENV = "LAUNCHPAD_NO_UPDATE_NOTIFIER";
|
|
18626
|
-
var CACHE_FILE =
|
|
20246
|
+
var CACHE_FILE = join20(homedir4(), ".launchpad", "update-check.json");
|
|
18627
20247
|
function readCache2() {
|
|
18628
20248
|
try {
|
|
18629
|
-
const raw = JSON.parse(
|
|
20249
|
+
const raw = JSON.parse(readFileSync24(CACHE_FILE, "utf8"));
|
|
18630
20250
|
if (typeof raw === "object" && raw !== null && typeof raw.checkedAt === "number") {
|
|
18631
20251
|
const latest = raw.latest;
|
|
18632
20252
|
return {
|
|
@@ -18639,23 +20259,23 @@ function readCache2() {
|
|
|
18639
20259
|
}
|
|
18640
20260
|
function writeCache2(state) {
|
|
18641
20261
|
try {
|
|
18642
|
-
|
|
18643
|
-
|
|
20262
|
+
mkdirSync6(join20(homedir4(), ".launchpad"), { recursive: true });
|
|
20263
|
+
writeFileSync10(CACHE_FILE, `${JSON.stringify(state)}
|
|
18644
20264
|
`, { mode: 384 });
|
|
18645
20265
|
} catch {}
|
|
18646
20266
|
}
|
|
18647
|
-
var SKILLS_HINT_MARKER =
|
|
20267
|
+
var SKILLS_HINT_MARKER = join20(homedir4(), ".launchpad", "skills-hint-shown");
|
|
18648
20268
|
function absentHintShown() {
|
|
18649
20269
|
try {
|
|
18650
|
-
return
|
|
20270
|
+
return existsSync19(SKILLS_HINT_MARKER);
|
|
18651
20271
|
} catch {
|
|
18652
20272
|
return false;
|
|
18653
20273
|
}
|
|
18654
20274
|
}
|
|
18655
20275
|
function markAbsentHintShown() {
|
|
18656
20276
|
try {
|
|
18657
|
-
|
|
18658
|
-
|
|
20277
|
+
mkdirSync6(join20(homedir4(), ".launchpad"), { recursive: true });
|
|
20278
|
+
writeFileSync10(SKILLS_HINT_MARKER, `${Date.now()}
|
|
18659
20279
|
`, { mode: 384 });
|
|
18660
20280
|
} catch {}
|
|
18661
20281
|
}
|
|
@@ -18757,8 +20377,8 @@ var refreshUpdateCacheCommand = {
|
|
|
18757
20377
|
// src/telemetry.ts
|
|
18758
20378
|
import { spawn as spawn7 } from "node:child_process";
|
|
18759
20379
|
import { homedir as homedir5 } from "node:os";
|
|
18760
|
-
import { join as
|
|
18761
|
-
import { existsSync as
|
|
20380
|
+
import { join as join21 } from "node:path";
|
|
20381
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync7, readFileSync as readFileSync25, writeFileSync as writeFileSync11 } from "node:fs";
|
|
18762
20382
|
import { randomUUID } from "node:crypto";
|
|
18763
20383
|
var INTERNAL_EMIT_VERB = "__emit-telemetry";
|
|
18764
20384
|
var POSTHOG_HOST = "https://us.i.posthog.com";
|
|
@@ -18766,8 +20386,8 @@ var POSTHOG_PROJECT_KEY = "phc_CYaCuETanWc36TMTiB7cdkdnmPPhFZCkDGmWGLaNkXnb";
|
|
|
18766
20386
|
var CAPTURE_PATH = "/i/v0/e/";
|
|
18767
20387
|
var SEND_TIMEOUT_MS = 3000;
|
|
18768
20388
|
var APP = "launchpad-cli";
|
|
18769
|
-
var DEVICE_ID_FILE =
|
|
18770
|
-
var FIRST_RUN_MARKER =
|
|
20389
|
+
var DEVICE_ID_FILE = join21(homedir5(), ".launchpad", "telemetry-id.json");
|
|
20390
|
+
var FIRST_RUN_MARKER = join21(homedir5(), ".launchpad", "telemetry-notice-shown");
|
|
18771
20391
|
function buildEvent(ctx, identity, nowMs) {
|
|
18772
20392
|
const properties = {
|
|
18773
20393
|
app: APP,
|
|
@@ -18834,15 +20454,15 @@ async function resolveIdentityReal() {
|
|
|
18834
20454
|
}
|
|
18835
20455
|
function getOrCreateDeviceId() {
|
|
18836
20456
|
try {
|
|
18837
|
-
const raw = JSON.parse(
|
|
20457
|
+
const raw = JSON.parse(readFileSync25(DEVICE_ID_FILE, "utf8"));
|
|
18838
20458
|
const id2 = raw?.deviceId;
|
|
18839
20459
|
if (typeof id2 === "string" && id2)
|
|
18840
20460
|
return id2;
|
|
18841
20461
|
} catch {}
|
|
18842
20462
|
const id = randomUUID();
|
|
18843
20463
|
try {
|
|
18844
|
-
|
|
18845
|
-
|
|
20464
|
+
mkdirSync7(join21(homedir5(), ".launchpad"), { recursive: true });
|
|
20465
|
+
writeFileSync11(DEVICE_ID_FILE, `${JSON.stringify({ deviceId: id })}
|
|
18846
20466
|
`, {
|
|
18847
20467
|
mode: 384
|
|
18848
20468
|
});
|
|
@@ -18912,15 +20532,15 @@ function telemetryNoticeLine() {
|
|
|
18912
20532
|
}
|
|
18913
20533
|
function firstRunNoticeShown() {
|
|
18914
20534
|
try {
|
|
18915
|
-
return
|
|
20535
|
+
return existsSync20(FIRST_RUN_MARKER);
|
|
18916
20536
|
} catch {
|
|
18917
20537
|
return false;
|
|
18918
20538
|
}
|
|
18919
20539
|
}
|
|
18920
20540
|
function markFirstRunNotice() {
|
|
18921
20541
|
try {
|
|
18922
|
-
|
|
18923
|
-
|
|
20542
|
+
mkdirSync7(join21(homedir5(), ".launchpad"), { recursive: true });
|
|
20543
|
+
writeFileSync11(FIRST_RUN_MARKER, `${Date.now()}
|
|
18924
20544
|
`, { mode: 384 });
|
|
18925
20545
|
} catch {}
|
|
18926
20546
|
}
|
|
@@ -18985,22 +20605,22 @@ import { createInterface as createInterface7 } from "node:readline/promises";
|
|
|
18985
20605
|
import { platform } from "node:os";
|
|
18986
20606
|
|
|
18987
20607
|
// src/report/breadcrumb.ts
|
|
18988
|
-
import { writeFileSync as
|
|
20608
|
+
import { writeFileSync as writeFileSync12, readFileSync as readFileSync26, mkdirSync as mkdirSync8 } from "node:fs";
|
|
18989
20609
|
import { homedir as homedir6 } from "node:os";
|
|
18990
|
-
import { join as
|
|
20610
|
+
import { join as join22, dirname as dirname14 } from "node:path";
|
|
18991
20611
|
function breadcrumbPath() {
|
|
18992
|
-
return
|
|
20612
|
+
return join22(homedir6(), ".launchpad", "last-run.json");
|
|
18993
20613
|
}
|
|
18994
20614
|
function writeBreadcrumb(verb, exit) {
|
|
18995
20615
|
try {
|
|
18996
20616
|
const p = breadcrumbPath();
|
|
18997
|
-
|
|
18998
|
-
|
|
20617
|
+
mkdirSync8(dirname14(p), { recursive: true });
|
|
20618
|
+
writeFileSync12(p, JSON.stringify({ verb, exit, ts: Date.now() }), "utf8");
|
|
18999
20619
|
} catch {}
|
|
19000
20620
|
}
|
|
19001
20621
|
function readBreadcrumb() {
|
|
19002
20622
|
try {
|
|
19003
|
-
const raw = JSON.parse(
|
|
20623
|
+
const raw = JSON.parse(readFileSync26(breadcrumbPath(), "utf8"));
|
|
19004
20624
|
if (typeof raw !== "object" || raw === null)
|
|
19005
20625
|
return null;
|
|
19006
20626
|
const r = raw;
|
|
@@ -19033,7 +20653,7 @@ function realDeps5() {
|
|
|
19033
20653
|
readBreadcrumb
|
|
19034
20654
|
};
|
|
19035
20655
|
}
|
|
19036
|
-
function
|
|
20656
|
+
function parseArgs20(args) {
|
|
19037
20657
|
let title;
|
|
19038
20658
|
let message;
|
|
19039
20659
|
const positionalParts = [];
|
|
@@ -19064,7 +20684,7 @@ function parseArgs19(args) {
|
|
|
19064
20684
|
var NOUN = { bug: "bug report", feature: "feature request" };
|
|
19065
20685
|
async function runReport(kind, args, io, deps) {
|
|
19066
20686
|
const verb = kind;
|
|
19067
|
-
const parsed =
|
|
20687
|
+
const parsed = parseArgs20(args);
|
|
19068
20688
|
let message = parsed.message ?? parsed.positional ?? "";
|
|
19069
20689
|
let title = parsed.title ?? "";
|
|
19070
20690
|
if (message === "" && deps.isTty()) {
|
|
@@ -19166,6 +20786,7 @@ var COMMANDS = [
|
|
|
19166
20786
|
logoutCommand,
|
|
19167
20787
|
appsCommand,
|
|
19168
20788
|
whoamiCommand,
|
|
20789
|
+
agreementCommand,
|
|
19169
20790
|
createCommand,
|
|
19170
20791
|
cloneCommand,
|
|
19171
20792
|
deployCommand,
|
|
@@ -19186,6 +20807,8 @@ var COMMANDS = [
|
|
|
19186
20807
|
watchCommand,
|
|
19187
20808
|
recoverCommand,
|
|
19188
20809
|
destroyCommand,
|
|
20810
|
+
disableCommand,
|
|
20811
|
+
enableCommand,
|
|
19189
20812
|
rollbackCommand,
|
|
19190
20813
|
groupsCommand,
|
|
19191
20814
|
secretsCommand,
|
|
@@ -19203,7 +20826,7 @@ var COMMANDS = [
|
|
|
19203
20826
|
];
|
|
19204
20827
|
async function dispatch(argv, io, commands = COMMANDS, deps = {}) {
|
|
19205
20828
|
if (argv.length === 0 || argv[0] === "--help" || argv[0] === "-h") {
|
|
19206
|
-
|
|
20829
|
+
printHelp9(io, commands);
|
|
19207
20830
|
return 0;
|
|
19208
20831
|
}
|
|
19209
20832
|
if (argv[0] === "--version" || argv[0] === "-v") {
|
|
@@ -19240,6 +20863,12 @@ async function runCliFloorPreflight(verb, args, io, deps) {
|
|
|
19240
20863
|
io.err(error.message);
|
|
19241
20864
|
return EXIT_CLI_UPGRADE_REQUIRED;
|
|
19242
20865
|
}
|
|
20866
|
+
if (error instanceof AgreementRequiredError) {
|
|
20867
|
+
if (verb === "destroy")
|
|
20868
|
+
return null;
|
|
20869
|
+
io.err(error.message);
|
|
20870
|
+
return EXIT_AGREEMENT_REQUIRED;
|
|
20871
|
+
}
|
|
19243
20872
|
io.err(`launchpad ${verb}: version preflight failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
19244
20873
|
return 1;
|
|
19245
20874
|
}
|
|
@@ -19270,7 +20899,7 @@ function requiresCliFloorPreflight(verb, args) {
|
|
|
19270
20899
|
return args[0] === "status-revoke" || args[0] === "integrations";
|
|
19271
20900
|
return false;
|
|
19272
20901
|
}
|
|
19273
|
-
function
|
|
20902
|
+
function printHelp9(io, commands) {
|
|
19274
20903
|
io.out("launchpad — manage Launchpad-deployed apps from the command line.");
|
|
19275
20904
|
io.out("");
|
|
19276
20905
|
io.out("Usage:");
|