# 权限

插件调用系统操作、原生工具或网络代理时，先在 `permissions` 中写入对应权限。用户启用插件时，飞块展示这些请求，让用户授权。

例如，一个打开网页的动作可以声明：

```json
{
  "permissions": ["system.openExternal"]
}
```

## 权限名称

| 权限 | 对应接口 |
| --- | --- |
| `system.openExternal` | [system.openExternal()](./system.md#openexternal) |
| `system.openApplication` | [system.openApplication()](./system.md#openapplication) |
| `system.openPath` | [system.openPath()](./system.md#openpath) |
| `system.adjustVolume` | [system.adjustVolume()](./system.md#adjustvolume) |
| `system.sendHotkey` | [system.sendHotkey()](./system.md#sendhotkey) |
| `system.sendText` | [system.sendText()](./system.md#sendtext) |
| `system.captureScreen` | [system.captureScreen()](./system.md#capturescreen) |
| `system.lockScreen` | [system.lockScreen()](./system.md#lockscreen) |
| `system.sleepComputer` | [system.sleepComputer()](./system.md#sleepcomputer) |
| `system.sleepDisplay` | [system.sleepDisplay()](./system.md#sleepdisplay) |
| `system.runShortcut` | [system.runShortcut()](./system.md#runshortcut) |
| `native.execute` | [native.execute()](./native.md#execute) |
| `network.getJson` | [network.getJson()](./network.md#getjson) |
| `network.unrestricted` | 声明后台直接使用 Node.js 联网 |

发布状态、查询实例和调用已声明的插件服务不需要额外权限；它们根据清单中的功能声明确定调用范围。

## 两种网络来源

后台通过 `context.network.getJson()` 请求接口时，在 `networkOrigins` 中填写 HTTPS 来源。比如，请求 `https://api.example.com/weather`，填写 `https://api.example.com`。

页面直接通过 `fetch()` 或 WebSocket 连接时，在 `widgetConnectOrigins` 中填写来源。页面请求还受浏览器的 CORS 策略约束。

两个字段分别控制不同的调用入口，每个最多 8 项。填写 `["*"]` 表示允许任意来源，后台 JSON 代理仍使用公网 HTTPS 目标。字段定义见 [manifest.json](./manifest.md)。

## 系统授权

清单权限和操作系统授权是两件事。比如，用户同意插件发送热键后，还要在 macOS 中允许飞块使用辅助功能。遇到系统授权问题时，先检查对应系统设置，见[调试插件](../troubleshooting/diagnostics.md)。
