@adea-ai/app-framework 0.24.1 → 0.25.1

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
@@ -67,6 +67,7 @@ Commands (package `bin` entries):
67
67
  | `adea-sign-release-descriptors` | Sign channel descriptors for payloads every receipt qualified. |
68
68
  | `adea-publish-release` | Publish the current trusted release-assets attempt. |
69
69
  | `adea-finalize-release` | Publish a qualified Release Please draft as a prerelease. |
70
+ | `adea-verify-macos-signing` | On a Mac, check every nested Mach-O in an app is signed alike and the seal verifies. |
70
71
  | `adea-promote-release` | Promote the newest qualified daily to stable after the soak. |
71
72
  | `adea-cef-helper` | Print the CEF helper cache key, or build the helper. |
72
73
  | `adea-patch-windows-runtime` | Apply the checksum-guarded Windows runtime correction. |
@@ -542,6 +543,11 @@ Nothing is uploaded; publishing steps write a tree mirroring the feed's keys and
542
543
  the feed's release and stages the upload.
543
544
  - `adea-promote-release --local <config> <out>` promotes a qualified daily
544
545
  after the soak and stages release.json, index.json and the stable pointer.
546
+ A daily qualifies when it publishes every platform in `stablePlatforms`
547
+ (release-config.json; macOS only by default, add `windows-x64` and `linux-x64`
548
+ to require them). A stable promoted without a supported platform records it as
549
+ `missingPlatforms` in release.json. A daily short of a required platform is
550
+ `unqualified` with `reasons`.
545
551
  - `adea-finalize-release --local <config> <tag>` verifies a published release
546
552
  from the feed and lists its verified and missing platforms.
547
553
 
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bun
2
+ export {};
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env bun
2
+ import { runCli } from "./cli-runner.js";
3
+ import { verifyMacosBundleSigning } from "../release/macos-signing.js";
4
+ // src/cli/macos-signing-cli.ts
5
+ await runCli("Unable to check the app signing; run it on macOS with codesign.", async () => {
6
+ const [app, flag, ...extra] = process.argv.slice(2);
7
+ if (!app || extra.length || ![void 0, "--hardened"].includes(flag)) throw new Error("usage");
8
+ const report = await verifyMacosBundleSigning({
9
+ app,
10
+ requireHardened: flag === "--hardened"
11
+ });
12
+ process.stdout.write(JSON.stringify(report, null, 2) + "\n");
13
+ if (report.problems.length) process.exitCode = 1;
14
+ });
@@ -27,6 +27,7 @@ function createChannelProofVerifier(options) {
27
27
  const context = options.context ?? "adea-invoke-v1";
28
28
  if (!field(context) || !Number.isSafeInteger(maxNonces) || maxNonces < 1 || !Number.isSafeInteger(maxBodyBytes) || maxBodyBytes < 1) throw new Error("Invalid channel proof configuration");
29
29
  const nonces = /* @__PURE__ */ new Map();
30
+ let earliest = Infinity;
30
31
  return { verify(input) {
31
32
  if (!field(input?.channelId) || !field(input.credentialId) || !field(input.nonce) || typeof input.body !== "string" || Buffer.byteLength(input.body) > maxBodyBytes || typeof input.timestamp !== "string" || !/^\d{1,16}$/.test(input.timestamp) || typeof input.proof !== "string" || !/^[A-Za-z0-9_-]{43}$/.test(input.proof)) return {
32
33
  ok: false,
@@ -65,7 +66,11 @@ function createChannelProofVerifier(options) {
65
66
  ok: false,
66
67
  code: "unauthenticated"
67
68
  };
68
- for (const [key, expiry] of nonces) if (expiry < at) nonces.delete(key);
69
+ if (earliest < at) {
70
+ earliest = Infinity;
71
+ for (const [key, expiry] of nonces) if (expiry < at) nonces.delete(key);
72
+ else if (expiry < earliest) earliest = expiry;
73
+ }
69
74
  const key = `${input.channelId}\0${input.credentialId}\0${input.nonce}`;
70
75
  if (nonces.has(key)) return {
71
76
  ok: false,
@@ -76,6 +81,7 @@ function createChannelProofVerifier(options) {
76
81
  code: "capacity"
77
82
  };
78
83
  nonces.set(key, timestamp + 6e4);
84
+ if (timestamp + 6e4 < earliest) earliest = timestamp + 6e4;
79
85
  return {
80
86
  ok: true,
81
87
  principal: channel.principal
@@ -1 +1 @@
1
- {"version":"0.24.1","commit":"d89bf3a900387a95245169973af6d7f28eb95ba8"}
1
+ {"version":"0.25.1","commit":"c507ecdd7963214e7edfab7ceb5273bef39793ba"}
@@ -116,6 +116,7 @@ export declare function runLocalPromotion(options: {
116
116
  fetch: FetchFunction;
117
117
  }): Promise<{
118
118
  status: 'held' | 'soaking' | 'unqualified';
119
+ reasons?: string[] | undefined;
119
120
  plan?: Readonly<{
120
121
  schema: 1;
121
122
  base: string;
@@ -124,6 +125,7 @@ export declare function runLocalPromotion(options: {
124
125
  } | {
125
126
  status: 'stable';
126
127
  tag: string;
128
+ reasons?: string[] | undefined;
127
129
  plan?: Readonly<{
128
130
  schema: 1;
129
131
  base: string;
@@ -300,6 +300,17 @@ async function stageLocalRelease(options) {
300
300
  };
301
301
  return writeStagedTree(options.out, feed, uploads, releaseDocuments(feed, updated, release));
302
302
  }
303
+ /**
304
+ * Platforms a daily must publish before it can become stable: `stablePlatforms` in
305
+ * release-config.json, macOS only by default. List more (up to every supported platform) to
306
+ * require them; a stable promoted without a supported platform records it as `missingPlatforms`.
307
+ */
308
+ function stablePlatforms(config) {
309
+ const value = object(config) ? config.stablePlatforms : void 0;
310
+ if (value === void 0) return ["macos-arm64"];
311
+ if (!Array.isArray(value) || !value.length || new Set(value).size !== value.length || !value.every((name) => typeof name === "string" && Object.hasOwn(platformTargets, name))) throw new Error("Invalid stablePlatforms in the release configuration");
312
+ return value;
313
+ }
303
314
  /** Check a release the feed publishes: ledger, release.json and every signed descriptor. */
304
315
  async function verifyLocalRelease(options) {
305
316
  const local = localConfig(options.config);
@@ -327,8 +338,11 @@ async function verifyLocalRelease(options) {
327
338
  async function runLocalPromotion(options) {
328
339
  const local = localConfig(options.config);
329
340
  const feed = local.feed;
341
+ const required = stablePlatforms(local.config);
330
342
  const ledger = await readFeedLedger(feed, options.fetch);
331
343
  let plan;
344
+ const qualified = /* @__PURE__ */ new Map();
345
+ const reasons = [];
332
346
  return {
333
347
  ...await promoteDailyRelease({
334
348
  now: timestamp(options.now),
@@ -346,7 +360,7 @@ async function runLocalPromotion(options) {
346
360
  }));
347
361
  },
348
362
  async qualify(release) {
349
- await verifyFeedRelease({
363
+ const { platforms } = await verifyFeedRelease({
350
364
  config: local.config,
351
365
  feed,
352
366
  tag: release.tag,
@@ -355,9 +369,16 @@ async function runLocalPromotion(options) {
355
369
  fetch: options.fetch,
356
370
  channels: ["stable"]
357
371
  });
372
+ qualified.set(release.tag, platforms);
373
+ const missing = required.filter((name) => !platforms.includes(name));
374
+ if (missing.length) {
375
+ reasons.push(`${release.tag} lacks ${missing.join(", ")}; publish them or relax stablePlatforms in release-config.json`);
376
+ return false;
377
+ }
358
378
  return true;
359
379
  },
360
380
  async markStable(selected, at) {
381
+ const absent = Object.keys(platformTargets).filter((name) => !qualified.get(selected.tag)?.includes(name));
361
382
  const entry = ledger.releases.find((item) => item.tag === selected.tag);
362
383
  const remote = await readFeedRelease(feed, selected.tag, options.fetch);
363
384
  if (!entry || !remote || entry.kind === "dev") throw new Error("Release changed during promotion");
@@ -376,11 +397,13 @@ async function runLocalPromotion(options) {
376
397
  }, feed.app);
377
398
  plan = await writeStagedTree(options.out, feed, [], releaseDocuments(feed, updated, {
378
399
  ...remote,
379
- channel: "stable"
400
+ channel: "stable",
401
+ ...absent.length ? { missingPlatforms: absent } : {}
380
402
  }));
381
403
  }
382
404
  }
383
405
  }),
406
+ ...reasons.length && !plan ? { reasons } : {},
384
407
  ...plan ? { plan } : {}
385
408
  };
386
409
  }
@@ -0,0 +1,27 @@
1
+ export type CodesignRun = (args: readonly string[]) => {
2
+ status: number;
3
+ output: string;
4
+ };
5
+ type BinarySigning = Readonly<{
6
+ path: string;
7
+ signature: 'adhoc' | 'identity' | 'unsigned';
8
+ team?: string;
9
+ hardened: boolean;
10
+ }>;
11
+ export type MacosSigningReport = Readonly<{
12
+ binaries: readonly BinarySigning[];
13
+ problems: readonly string[];
14
+ }>;
15
+ /**
16
+ * Check that every Mach-O file in a macOS app bundle carries a code signature of one kind and
17
+ * that the bundle's seal verifies. An ad-hoc build (no Developer ID) needs every nested binary
18
+ * ad-hoc signed; a Developer ID build needs every binary signed by the same team, and with
19
+ * `requireHardened` the hardened runtime on each. Notarization is separate: it needs a
20
+ * Developer ID and is not checked here.
21
+ */
22
+ export declare function verifyMacosBundleSigning(options: {
23
+ app: string;
24
+ requireHardened?: boolean;
25
+ codesign?: CodesignRun;
26
+ }): Promise<MacosSigningReport>;
27
+ export {};
@@ -0,0 +1,101 @@
1
+ import { open, readdir } from "node:fs/promises";
2
+ import { join, relative } from "node:path";
3
+ import { spawnSync } from "node:child_process";
4
+ // src/release/macos-signing.ts
5
+ var MACH_O_MAGIC = /* @__PURE__ */ new Set([
6
+ 4277009102,
7
+ 4277009103,
8
+ 3472551422,
9
+ 3489328638,
10
+ 3405691582,
11
+ 3199925962,
12
+ 3405691583,
13
+ 3216703178
14
+ ]);
15
+ var MAX_FILES = 2e5;
16
+ var run = (args) => {
17
+ const result = spawnSync("codesign", [...args], {
18
+ encoding: "utf8",
19
+ maxBuffer: 16777216
20
+ });
21
+ if (result.error) throw result.error;
22
+ return {
23
+ status: result.status ?? 1,
24
+ output: `${result.stdout}${result.stderr}`
25
+ };
26
+ };
27
+ async function isMachO(path) {
28
+ const handle = await open(path, "r");
29
+ try {
30
+ const head = Buffer.alloc(4);
31
+ const { bytesRead } = await handle.read(head, 0, 4, 0);
32
+ return bytesRead === 4 && MACH_O_MAGIC.has(head.readUInt32BE(0));
33
+ } finally {
34
+ await handle.close();
35
+ }
36
+ }
37
+ async function* machOFiles(root) {
38
+ let seen = 0;
39
+ const stack = [root];
40
+ while (stack.length) {
41
+ const directory = stack.pop();
42
+ for (const entry of await readdir(directory, { withFileTypes: true })) {
43
+ if (++seen > MAX_FILES) throw new Error("Bundle has too many files to inspect");
44
+ const path = join(directory, entry.name);
45
+ if (entry.isDirectory()) stack.push(path);
46
+ else if (entry.isFile() && await isMachO(path)) yield path;
47
+ }
48
+ }
49
+ }
50
+ /**
51
+ * Check that every Mach-O file in a macOS app bundle carries a code signature of one kind and
52
+ * that the bundle's seal verifies. An ad-hoc build (no Developer ID) needs every nested binary
53
+ * ad-hoc signed; a Developer ID build needs every binary signed by the same team, and with
54
+ * `requireHardened` the hardened runtime on each. Notarization is separate: it needs a
55
+ * Developer ID and is not checked here.
56
+ */
57
+ async function verifyMacosBundleSigning(options) {
58
+ const codesign = options.codesign ?? run;
59
+ const problems = [];
60
+ const binaries = [];
61
+ for await (const file of machOFiles(options.app)) {
62
+ const name = relative(options.app, file);
63
+ const { status, output } = codesign(["-dvv", file]);
64
+ if (status !== 0 || /code object is not signed/i.test(output)) {
65
+ binaries.push({
66
+ path: name,
67
+ signature: "unsigned",
68
+ hardened: false
69
+ });
70
+ problems.push(`${name} is not signed`);
71
+ continue;
72
+ }
73
+ const adhoc = /^Signature=adhoc$/m.test(output);
74
+ const team = output.match(/^TeamIdentifier=(\S+)$/m)?.[1];
75
+ const flags = output.match(/flags=0x[0-9a-f]+\(([^)]*)\)/)?.[1] ?? "";
76
+ binaries.push({
77
+ path: name,
78
+ signature: adhoc ? "adhoc" : "identity",
79
+ ...team && team !== "not" ? { team } : {},
80
+ hardened: flags.split(",").includes("runtime")
81
+ });
82
+ }
83
+ if (!binaries.length) problems.push("No Mach-O files found; is this a macOS app bundle?");
84
+ if (new Set(binaries.filter((item) => item.signature !== "unsigned").map((item) => item.signature)).size > 1) problems.push("Binaries mix ad-hoc and identity signatures");
85
+ if (new Set(binaries.filter((item) => item.signature === "identity").map((item) => item.team)).size > 1) problems.push("Binaries are signed by different teams");
86
+ if (options.requireHardened) {
87
+ for (const item of binaries) if (item.signature !== "unsigned" && !item.hardened) problems.push(`${item.path} lacks the hardened runtime`);
88
+ }
89
+ const seal = codesign([
90
+ "--verify",
91
+ "--deep",
92
+ "--strict",
93
+ options.app
94
+ ]);
95
+ if (seal.status !== 0) problems.push(`Bundle seal does not verify: ${seal.output.trim().slice(0, 500)}`);
96
+ return {
97
+ binaries,
98
+ problems
99
+ };
100
+ }
101
+ export { verifyMacosBundleSigning };
@@ -21,6 +21,8 @@ export type FeedRelease = Readonly<{
21
21
  channel: FeedChannel;
22
22
  publishedAt: string;
23
23
  assets: readonly FeedAsset[];
24
+ /** Supported platforms a stable release was promoted without; present only on such stables. */
25
+ missingPlatforms?: readonly string[];
24
26
  }>;
25
27
  export type LedgerEntry = Readonly<{
26
28
  tag: string;
@@ -41,7 +41,13 @@ var channelOf = (tag) => tag.includes("-dev.") ? "dev" : "daily";
41
41
  /** Validate a release.json or channel pointer: a tag of its channel and a bounded,
42
42
  * unique asset inventory. */
43
43
  function parseFeedRelease(value) {
44
- if (!record(value) || !exactKeys(value, [
44
+ if (!record(value) || !exactKeys(value, Object.hasOwn(value, "missingPlatforms") ? [
45
+ "tag",
46
+ "channel",
47
+ "publishedAt",
48
+ "assets",
49
+ "missingPlatforms"
50
+ ] : [
45
51
  "tag",
46
52
  "channel",
47
53
  "publishedAt",
@@ -65,11 +71,14 @@ function parseFeedRelease(value) {
65
71
  sha256: asset.sha256
66
72
  };
67
73
  });
74
+ const allowed = value.missingPlatforms;
75
+ if (allowed !== void 0 && (value.channel !== "stable" || !Array.isArray(allowed) || allowed.length < 1 || allowed.length > 8 || new Set(allowed).size !== allowed.length || !allowed.every((name) => typeof name === "string" && segment.test(name)))) throw new Error("Invalid feed release");
68
76
  return {
69
77
  tag: value.tag,
70
78
  channel: value.channel,
71
79
  publishedAt: value.publishedAt,
72
- assets
80
+ assets,
81
+ ...allowed ? { missingPlatforms: allowed } : {}
73
82
  };
74
83
  }
75
84
  /** Validate the ledger: this app, at most MAX_LEDGER_RELEASES unique tags, newest first,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adea-ai/app-framework",
3
- "version": "0.24.1",
3
+ "version": "0.25.1",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,6 +20,7 @@
20
20
  "adea-sign-release-descriptors": "./dist/cli/release-descriptor-staging-cli.js",
21
21
  "adea-toolchain-identity": "./dist/cli/toolchain-identity-cli.js",
22
22
  "adea-update-app-framework": "./dist/cli/framework-update-cli.js",
23
+ "adea-verify-macos-signing": "./dist/cli/macos-signing-cli.js",
23
24
  "create-adea-app": "./dist/cli/create-application-cli.js"
24
25
  },
25
26
  "files": [
@@ -344,8 +345,8 @@
344
345
  "tar": "^7.5.22"
345
346
  },
346
347
  "devDependencies": {
347
- "@adea-ai/ui": "0.149.0",
348
- "@babel/core": "^8.0.6",
348
+ "@adea-ai/ui": "0.150.0",
349
+ "@babel/core": "8.0.10",
349
350
  "@babel/preset-typescript": "^8.0.1",
350
351
  "@happy-dom/global-registrator": "^21.0.4",
351
352
  "@playwright/test": "1.64.1",
@@ -353,19 +354,19 @@
353
354
  "@types/bun": "^1.4.4",
354
355
  "@types/node": "^26.0.0",
355
356
  "babel-preset-solid": "^1.9.15",
356
- "code-foundry": "1.53.10",
357
+ "code-foundry": "1.53.11",
357
358
  "knip": "6.43.0",
358
359
  "lucide-solid": "^1.51.0",
359
360
  "oxfmt": "0.75.0",
360
361
  "oxlint": "1.90.0",
361
- "solid-js": "1.9.17",
362
+ "solid-js": "1.9.18",
362
363
  "typescript": "^7.0.2",
363
364
  "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
364
365
  "vite-plugin-solid": "2.11.14",
365
366
  "vite-plus": "1.4.0"
366
367
  },
367
368
  "peerDependencies": {
368
- "@adea-ai/ui": "^0.146.10 || ^0.147.0 || ^0.148.0 || ^0.149.0",
369
+ "@adea-ai/ui": "^0.146.10 || ^0.147.0 || ^0.148.0 || ^0.149.0 || ^0.150.0",
369
370
  "lucide-solid": "^1.51.0",
370
371
  "solid-js": "^1.9.15"
371
372
  },