Files
rea/src/hopper/HopperMacPublisher.ts
T
morluto 4acda94b76 fix(hopper): recover provenance-verified Spotlight exits
Verify the native helper's sealed identifier and pinned Apple signing team in BridgeLauncher, then carry that provenance to HopperClient. Only a verified native helper's complete not-found exit confirms no document handoff, allowing runtime and target-lease cleanup and retry; wrappers retain unknown document state.

Share publisher identity with setup through the domain contract. Correct fixture teardown ordering and parameterized MCP coverage. Validation: 54 focused tests passed across boundary, CLI, MCP acceptance, diagnostics and installer coverage (one Linux-only case skipped); check:fast passed. Real codesign verification accepted the installed official Hopper helper; Spotlight failures and bridge recovery used process fixtures.
2026-10-14 06:19:47 +08:00

37 lines
1.2 KiB
TypeScript

import { HOPPER_PUBLISHER } from "../domain/hopperPublisher.js";
import { macDeveloperIdRequirement } from "../process/MacCodeSignature.js";
import { execFileOutput } from "../process/ExecFileOutput.js";
/** Failure or unavailable verification leaves custom/native provenance unknown. */
export const verifyMacHopperNativeHelper = async (
launcherPath: string,
environment: Readonly<NodeJS.ProcessEnv>,
signal?: AbortSignal,
): Promise<"verified" | "unknown"> => {
// codesign treats a bare name as a local file, while spawn searches PATH.
// Without an explicit path they need not identify the same executable.
if (!launcherPath.includes("/")) return "unknown";
try {
await execFileOutput(
"/usr/bin/codesign",
[
"--verify",
"--strict",
`-R${macDeveloperIdRequirement("hopper", HOPPER_PUBLISHER.teamIdentifier)}`,
launcherPath,
],
{
env: environment,
...(signal === undefined ? {} : { signal }),
timeout: 5_000,
stopSignal: "SIGKILL",
},
);
return "verified";
} catch (cause: unknown) {
// Optional provenance: a failed check must never authorize lease release.
void cause;
return "unknown";
}
};