# demo-01-exposure-probe 安全基线的最小探针:preload 只暴露 `window.api.ping`,页面里断言 `window.api` 可用、`window.require` 与 `window.ipcRenderer` 不可用。 ## 运行 ```bash pnpm --filter @tutorial/05-preload-and-contextbridge-demo-01-exposure-probe start ``` ## 验证 ```bash pnpm --filter @tutorial/05-preload-and-contextbridge-demo-01-exposure-probe smoke # {"evt":"smoke","ok":true,"hasApi":true,"hasRequire":false,"hasIpcRenderer":false} ``` ## 说明 `contextIsolation: true` + `sandbox: true` + `nodeIntegration: false` 是三条硬约束。 preload 用 `contextBridge.exposeInMainWorld("api", { ping })` 暴露一个方法; 页面看不到 `ipcRenderer`,也看不到 Node 的 `require`。 ## 已知限制 - 只在 macOS arm64 验证;探针只检查三个全局对象,不检查所有 API。