Q120: every IPC call passes one gate - the app's own page, input checked against a typed contract
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
43591d4c99
commit
04c8cce0c4
10 files changed
+435
-103
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { z } from "zod";
|
||||
import type { DesktopApi } from "../../../shared/desktop-api";
|
||||
import { collaborationContracts } from "./collaboration";
|
||||
import { organizationContracts } from "./organization";
|
||||
import { platformContracts } from "./platform";
|
||||
|
||||
/** Every desktop API method the renderer invokes (not the event subscription or the constants). */
|
||||
export type InvokedMethod = { [K in keyof DesktopApi]: DesktopApi[K] extends (...args: never[]) => Promise<unknown> ? K : never }[keyof DesktopApi];
|
||||
export type InputOf<K extends InvokedMethod> = Parameters<DesktopApi[K]> extends [infer I] ? I : undefined;
|
||||
|
||||
const noInput = z.undefined();
|
||||
|
||||
/** The runtime contract of each IPC call; a method without a schema, or a schema that disagrees with its type, fails the typecheck. */
|
||||
export const IPC_CONTRACTS: { [K in InvokedMethod]: z.ZodType<InputOf<K>> } = {
|
||||
loadSnapshot: noInput,
|
||||
pickDirectory: noInput,
|
||||
listConnectorCatalog: noInput,
|
||||
windowMinimize: noInput,
|
||||
windowMaximize: noInput,
|
||||
windowClose: noInput,
|
||||
...organizationContracts,
|
||||
...collaborationContracts,
|
||||
...platformContracts,
|
||||
};
|
||||
Reference in new issue
Block a user