@verentis/cli 0.2.32 → 0.2.33

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/README.md CHANGED
@@ -112,15 +112,15 @@ kind: Theme
112
112
  spec:
113
113
  assets:
114
114
  theme.css: theme/theme.css
115
- logo.light: theme/logo-light.svg
115
+ logo: theme/logo-light.svg
116
116
  favicon: theme/favicon.svg
117
117
  apple-touch-icon: theme/apple-touch-icon.png
118
118
  packaging:
119
119
  files: ["theme/*"]
120
120
  ```
121
121
 
122
- Allowed asset names: `theme.css`, `background`, `background.dark`, `logo.light`, `logo.dark`,
123
- `mark.light`, `mark.dark`, `favicon`, `apple-touch-icon`. `pack` expands each asset into a managed
122
+ Allowed asset names: `theme.css`, `background`, `background.dark`, `logo`, `logo.dark`,
123
+ `mark`, `mark.dark`, `favicon`, `apple-touch-icon`. `pack` expands each asset into a managed
124
124
  `spec.install` entry (`to: /.theme/<asset>`, with its MIME type); themes may not install anywhere
125
125
  else. The CLI enforces the Marketplace rules before packing:
126
126
 
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Command, Option } from 'commander';
3
3
  import { mkdir, stat, readFile, writeFile, readdir, glob, realpath, mkdtemp, rm, access } from 'fs/promises';
4
4
  import { tmpdir, homedir } from 'os';
5
- import { resolve, basename, dirname, posix, join, isAbsolute, relative, sep, extname } from 'path';
5
+ import { resolve, basename, dirname, posix, join, isAbsolute, sep, relative, extname } from 'path';
6
6
  import { execFile, spawn, spawnSync } from 'child_process';
7
7
  import { promisify, TextDecoder as TextDecoder$1 } from 'util';
8
8
  import * as tar from 'tar';
@@ -141,7 +141,7 @@ async function refreshIdentityToken(apiUrl, refreshToken, insecure) {
141
141
  `Session could not be renewed${payload?.error ? ` (${payload.error})` : ` (${res.status})`}. Run \`verentis login\` again.`
142
142
  );
143
143
  }
144
- var sleep = (ms) => new Promise((resolve16) => setTimeout(resolve16, ms));
144
+ var sleep = (ms) => new Promise((resolve17) => setTimeout(resolve17, ms));
145
145
 
146
146
  // src/auth/githubActions.ts
147
147
  var JWT_BEARER_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer";
@@ -1501,9 +1501,9 @@ var THEME_ASSET_NAMES = [
1501
1501
  "theme.css",
1502
1502
  "background",
1503
1503
  "background.dark",
1504
- "logo.light",
1504
+ "logo",
1505
1505
  "logo.dark",
1506
- "mark.light",
1506
+ "mark",
1507
1507
  "mark.dark",
1508
1508
  "favicon",
1509
1509
  "apple-touch-icon"
@@ -2919,7 +2919,7 @@ async function followExecution(api, workspaceId, executionId, json) {
2919
2919
  if (exec.status !== "Completed") process.exitCode = 1;
2920
2920
  return;
2921
2921
  }
2922
- await new Promise((resolve16) => setTimeout(resolve16, 1e3));
2922
+ await new Promise((resolve17) => setTimeout(resolve17, 1e3));
2923
2923
  }
2924
2924
  console.error("Timed out waiting for a terminal status \u2014 check `verentis exec get`.");
2925
2925
  process.exitCode = 1;
@@ -3739,15 +3739,15 @@ metadata:
3739
3739
  # readme: ./README.md
3740
3740
 
3741
3741
  # A theme replaces the workspace theme (/.theme). Map any of the theme assets to files in this package:
3742
- # theme.css, background, background.dark, logo.light, logo.dark, mark.light, mark.dark, favicon,
3742
+ # theme.css, background, background.dark, logo, logo.dark, mark, mark.dark, favicon,
3743
3743
  # apple-touch-icon (PNG only). Images may be SVG, PNG, JPEG or WebP (1 MiB each, backgrounds 2 MiB,
3744
3744
  # 4 MiB in total). \`verentis pack\` installs each one at /.theme/<asset>.
3745
3745
  spec:
3746
3746
  assets:
3747
3747
  theme.css: theme/theme.css
3748
- logo.light: theme/logo-light.svg
3748
+ logo: theme/logo-light.svg
3749
3749
  logo.dark: theme/logo-dark.svg
3750
- mark.light: theme/mark-light.svg
3750
+ mark: theme/mark-light.svg
3751
3751
  mark.dark: theme/mark-dark.svg
3752
3752
  favicon: theme/favicon.svg
3753
3753
  # background: theme/background.jpg
@@ -4597,6 +4597,140 @@ function findPlaceholders(text) {
4597
4597
  }
4598
4598
  return placeholders;
4599
4599
  }
4600
+ var MAX_SCRIPT_FILE_ACCESS = 16;
4601
+ var MAX_PACKAGE_FILE_ACCESS = 64;
4602
+ var MAX_BOUNDARY_BYTES = 2048;
4603
+ var READ_ACTIONS = ["node.file.read"];
4604
+ var WRITE_ACTIONS = ["node.file.read", "node.node.create", "node.node.update", "node.journal.create"];
4605
+ var IDENTIFIER = "00000000-0000-0000-0000-000000000000";
4606
+ var boundaryEntry = (type, mode) => ({ type, identifier: IDENTIFIER, actions: mode === "write" ? WRITE_ACTIONS : READ_ACTIONS });
4607
+ function estimateBoundaryBytes(modes, kind) {
4608
+ const implicit = kind === "script" ? [boundaryEntry("Node", "write")] : [boundaryEntry("Node", "write"), boundaryEntry("NodeExact", "read")];
4609
+ return Buffer.byteLength(JSON.stringify([...implicit, ...modes.map((mode) => boundaryEntry("NodePath", mode))]));
4610
+ }
4611
+ function validateFileAccess(value, label, max, kind = "document") {
4612
+ if (value === void 0) return [];
4613
+ if (!Array.isArray(value)) return [`${label} must be a list of { path, mode, reason } entries.`];
4614
+ const errors = [];
4615
+ if (value.length > max) errors.push(`${label} declares ${value.length} entries; at most ${max} are allowed.`);
4616
+ value.forEach((entry, index) => {
4617
+ const at = `${label}[${index}]`;
4618
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
4619
+ errors.push(`${at} must be a mapping with path and mode.`);
4620
+ return;
4621
+ }
4622
+ const item = entry;
4623
+ if (item.mode !== "read" && item.mode !== "write") errors.push(`${at}.mode must be 'read' or 'write'.`);
4624
+ if (item.reason !== void 0 && (typeof item.reason !== "string" || item.reason.length > 500)) {
4625
+ errors.push(`${at}.reason must be a string of at most 500 characters.`);
4626
+ }
4627
+ const pathError = filePathError(item.path);
4628
+ if (pathError) errors.push(`${at}.path ${pathError}`);
4629
+ if (item.origin !== void 0) {
4630
+ const origin = item.origin;
4631
+ if (!origin || typeof origin !== "object" || origin.kind !== "script" && origin.kind !== "document" || typeof origin.name !== "string" || !origin.name.trim()) {
4632
+ errors.push(`${at}.origin needs kind 'script' or 'document' and a name.`);
4633
+ }
4634
+ }
4635
+ });
4636
+ return [...errors, ...boundarySizeErrors(value, label, kind)];
4637
+ }
4638
+ function boundarySizeErrors(entries, label, kind) {
4639
+ const origins = /* @__PURE__ */ new Map();
4640
+ for (const entry of entries) {
4641
+ if (!entry || typeof entry !== "object") continue;
4642
+ const item = entry;
4643
+ if (item.mode !== "read" && item.mode !== "write" || typeof item.path !== "string") continue;
4644
+ const origin = item.origin;
4645
+ const originKind = origin?.kind === "script" || origin?.kind === "document" ? origin.kind : kind;
4646
+ const name = typeof origin?.name === "string" ? origin.name.trim() : void 0;
4647
+ const key = `${originKind}:${name ?? ""}`;
4648
+ const group = origins.get(key) ?? { kind: originKind, name, paths: /* @__PURE__ */ new Map() };
4649
+ origins.set(key, group);
4650
+ const path = item.path.trim();
4651
+ group.paths.set(path, group.paths.get(path) === "write" ? "write" : item.mode);
4652
+ }
4653
+ const errors = [];
4654
+ for (const group of origins.values()) {
4655
+ const bytes = estimateBoundaryBytes([...group.paths.values()], group.kind);
4656
+ if (bytes <= MAX_BOUNDARY_BYTES) continue;
4657
+ const subject = group.name ? ` for ${group.kind} '${group.name}'` : "";
4658
+ errors.push(`${label}${subject} resolves to up to ${bytes} bytes of token boundaries, over the ${MAX_BOUNDARY_BYTES}-byte limit; declare fewer or broader grants (write grants are larger than read grants).`);
4659
+ }
4660
+ return errors;
4661
+ }
4662
+ function filePathError(value) {
4663
+ if (typeof value !== "string" || !value.trim()) return "is required.";
4664
+ const path = value.trim();
4665
+ if (path.length > 1024) return "exceeds 1024 characters.";
4666
+ if (/[\\*?[\]@\u0000-\u001f\u007f]/.test(path)) {
4667
+ return "must be a plain workspace path (no wildcards, backslashes or control characters).";
4668
+ }
4669
+ if (path.startsWith("/")) {
4670
+ let depth = 0;
4671
+ for (const segment of path.split("/").filter((part) => part && part !== ".")) {
4672
+ depth += segment === ".." ? -1 : 1;
4673
+ if (depth < 0) return "climbs above the workspace root.";
4674
+ }
4675
+ }
4676
+ return void 0;
4677
+ }
4678
+ async function collectScriptFileAccess(projectDir, spec) {
4679
+ const entries = [];
4680
+ const errors = [];
4681
+ const scripts = spec && typeof spec === "object" ? spec.scripts : void 0;
4682
+ if (!Array.isArray(scripts)) return { entries, errors };
4683
+ const root = resolve(projectDir);
4684
+ for (const script of scripts) {
4685
+ if (typeof script !== "string") continue;
4686
+ const directory = resolve(root, script);
4687
+ if (directory !== root && !directory.startsWith(root + sep)) {
4688
+ errors.push(`spec.scripts entry '${script}' is outside the package.`);
4689
+ continue;
4690
+ }
4691
+ if (!(await stat(directory).catch(() => null))?.isDirectory()) continue;
4692
+ const manifest = await findScriptRun(directory);
4693
+ if (!manifest) continue;
4694
+ const label = `${script}: file-access`;
4695
+ const declared = manifest.document["file-access"];
4696
+ const scriptErrors = validateFileAccess(declared, label, MAX_SCRIPT_FILE_ACCESS, "script");
4697
+ errors.push(...scriptErrors);
4698
+ if (scriptErrors.length > 0 || !Array.isArray(declared)) continue;
4699
+ const metadata = manifest.document.metadata;
4700
+ const name = typeof metadata?.name === "string" && metadata.name.trim() ? metadata.name.trim() : basename(directory);
4701
+ for (const entry of declared) {
4702
+ entries.push({
4703
+ path: entry.path.trim(),
4704
+ mode: entry.mode,
4705
+ ...typeof entry.reason === "string" ? { reason: entry.reason } : {},
4706
+ origin: { kind: "script", name }
4707
+ });
4708
+ }
4709
+ }
4710
+ return { entries, errors };
4711
+ }
4712
+ async function findScriptRun(directory) {
4713
+ const names = (await readdir(directory)).filter((name) => /\.ya?ml$/i.test(name)).sort((a, b) => rank(a) - rank(b) || a.localeCompare(b));
4714
+ for (const name of names) {
4715
+ try {
4716
+ const document = parse(await readFile(join(directory, name), "utf8"));
4717
+ if (document && typeof document === "object" && String(document.kind).replace(/-/g, "").toLowerCase() === "scriptrun") {
4718
+ return { document };
4719
+ }
4720
+ } catch {
4721
+ }
4722
+ }
4723
+ return void 0;
4724
+ }
4725
+ var rank = (name) => name === "verentis.run.yaml" ? 0 : name === "manifest.yaml" ? 1 : 2;
4726
+ function mergeFileAccess(spec, additions) {
4727
+ if (!spec || additions.length === 0) return spec;
4728
+ const existing = Array.isArray(spec["file-access"]) ? spec["file-access"] : [];
4729
+ const key = (entry) => `${entry.mode}|${entry.path}|${entry.origin ? `${entry.origin.kind}:${entry.origin.name}` : ""}`;
4730
+ const seen = new Set(existing.map(key));
4731
+ const added = additions.filter((entry) => !seen.has(key(entry)) && seen.add(key(entry)));
4732
+ return added.length === 0 ? spec : { ...spec, "file-access": [...existing, ...added] };
4733
+ }
4600
4734
 
4601
4735
  // src/vpkg/pack.ts
4602
4736
  async function pack(options) {
@@ -4637,6 +4771,15 @@ async function pack(options) {
4637
4771
  manifest = typeValidator?.expandForPack ? typeValidator.expandForPack(manifest) : manifest;
4638
4772
  const normalizedSpec = normalizeDependencies(manifest.spec);
4639
4773
  if (normalizedSpec !== manifest.spec) manifest = { ...manifest, spec: normalizedSpec };
4774
+ const fileAccessErrors = validateFileAccess(manifest.spec?.["file-access"], "spec.file-access", MAX_PACKAGE_FILE_ACCESS);
4775
+ const scriptAccess = await collectScriptFileAccess(projectDir, manifest.spec);
4776
+ fileAccessErrors.push(...scriptAccess.errors);
4777
+ if (fileAccessErrors.length > 0) throw new Error(`Invalid file-access:
4778
+ ${fileAccessErrors.join("\n ")}`);
4779
+ const accessSpec = mergeFileAccess(manifest.spec, scriptAccess.entries);
4780
+ if (accessSpec !== manifest.spec) manifest = { ...manifest, spec: accessSpec };
4781
+ const packageAccessErrors = validateFileAccess(manifest.spec?.["file-access"], "spec.file-access", MAX_PACKAGE_FILE_ACCESS);
4782
+ if (packageAccessErrors.length > 0) throw new Error(`Invalid file-access: ${packageAccessErrors.join(" ")}`);
4640
4783
  if (manifest !== authoredManifest) overrideApplied = true;
4641
4784
  const expandedInstall = expandedInstallSources(authoredManifest, manifest);
4642
4785
  const packageId = manifest.metadata["package-id"].toLowerCase();
@@ -5259,8 +5402,8 @@ function isNewerVersion(candidate, base) {
5259
5402
  return compareVersions(candidate, base) > 0;
5260
5403
  }
5261
5404
  function compareVersions(a, b) {
5262
- const pa = parse6(a);
5263
- const pb = parse6(b);
5405
+ const pa = parse7(a);
5406
+ const pb = parse7(b);
5264
5407
  for (let i = 0; i < 3; i++) {
5265
5408
  if (pa.main[i] !== pb.main[i]) return pa.main[i] < pb.main[i] ? -1 : 1;
5266
5409
  }
@@ -5287,7 +5430,7 @@ function compareVersions(a, b) {
5287
5430
  }
5288
5431
  return 0;
5289
5432
  }
5290
- function parse6(version) {
5433
+ function parse7(version) {
5291
5434
  const cleaned = version.trim().replace(/^v/i, "").split("+", 1)[0];
5292
5435
  const dash = cleaned.indexOf("-");
5293
5436
  const core = dash === -1 ? cleaned : cleaned.slice(0, dash);
@@ -5899,6 +6042,17 @@ function registerValidate(program2) {
5899
6042
  const issues = validateManifest(manifest);
5900
6043
  const payloadErrors = await validatorForKind(manifest.kind)?.validatePayload?.(dirname(manifestPath), manifest) ?? [];
5901
6044
  issues.push(...payloadErrors.map((message) => ({ level: "error", message })));
6045
+ const spec = manifest.spec;
6046
+ const scriptAccess = await collectScriptFileAccess(dirname(manifestPath), spec);
6047
+ issues.push(...[
6048
+ ...validateFileAccess(spec?.["file-access"], "spec.file-access", MAX_PACKAGE_FILE_ACCESS),
6049
+ ...scriptAccess.errors,
6050
+ ...validateFileAccess(
6051
+ mergeFileAccess(spec, scriptAccess.entries)?.["file-access"],
6052
+ "spec.file-access (with scripts)",
6053
+ MAX_PACKAGE_FILE_ACCESS
6054
+ ).filter((message) => message.includes("at most"))
6055
+ ].map((message) => ({ level: "error", message })));
5902
6056
  try {
5903
6057
  const payloadFiles = await resolvePayloadFiles(dirname(manifestPath), manifestPath, manifest);
5904
6058
  const templateInspection = await inspectPackagingTemplates(dirname(manifestPath), manifest, payloadFiles);