diff --git a/plugins/app/guest-js/index.ts b/plugins/app/guest-js/index.ts index d5e06aed..056f255e 100644 --- a/plugins/app/guest-js/index.ts +++ b/plugins/app/guest-js/index.ts @@ -5,22 +5,6 @@ /** * Get application metadata. * - * The APIs must be added to [`tauri.allowlist.app`](https://tauri.app/v1/api/config/#allowlistconfig.app) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "app": { - * "all": true, // enable all app APIs - * "show": true, - * "hide": true - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. - * * @module */ diff --git a/plugins/clipboard/guest-js/index.ts b/plugins/clipboard/guest-js/index.ts index f9a40d30..67f519ee 100644 --- a/plugins/clipboard/guest-js/index.ts +++ b/plugins/clipboard/guest-js/index.ts @@ -5,22 +5,6 @@ /** * Read and write to the system clipboard. * - * The APIs must be added to [`tauri.allowlist.clipboard`](https://tauri.app/v1/api/config/#allowlistconfig.clipboard) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "clipboard": { - * "all": true, // enable all Clipboard APIs - * "writeText": true, - * "readText": true - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. - * * @module */ diff --git a/plugins/dialog/guest-js/index.ts b/plugins/dialog/guest-js/index.ts index 50c6e64c..3d94a61e 100644 --- a/plugins/dialog/guest-js/index.ts +++ b/plugins/dialog/guest-js/index.ts @@ -113,11 +113,11 @@ async function open( /** * Open a file/directory selection dialog. * - * The selected paths are added to the filesystem and asset protocol allowlist scopes. + * The selected paths are added to the filesystem and asset protocol scopes. * When security is more important than the easy of use of this API, * prefer writing a dedicated command instead. * - * Note that the allowlist scope change is not persisted, so the values are cleared when the application is restarted. + * Note that the scope change is not persisted, so the values are cleared when the application is restarted. * You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope). * @example * ```typescript @@ -175,11 +175,11 @@ async function open( /** * Open a file/directory save dialog. * - * The selected path is added to the filesystem and asset protocol allowlist scopes. + * The selected path is added to the filesystem and asset protocol scopes. * When security is more important than the easy of use of this API, * prefer writing a dedicated command instead. * - * Note that the allowlist scope change is not persisted, so the values are cleared when the application is restarted. + * Note that the scope change is not persisted, so the values are cleared when the application is restarted. * You can save it to the filesystem using [tauri-plugin-persisted-scope](https://github.com/tauri-apps/tauri-plugin-persisted-scope). * @example * ```typescript diff --git a/plugins/fs/guest-js/index.ts b/plugins/fs/guest-js/index.ts index 93f4998c..bd16cd43 100644 --- a/plugins/fs/guest-js/index.ts +++ b/plugins/fs/guest-js/index.ts @@ -5,32 +5,6 @@ /** * Access the file system. * - * This package is also accessible with `window.__TAURI__.fs` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`. - * - * The APIs must be added to [`tauri.allowlist.fs`](https://tauri.app/v1/api/config/#allowlistconfig.fs) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "fs": { - * "all": true, // enable all FS APIs - * "readFile": true, - * "writeFile": true, - * "readDir": true, - * "copyFile": true, - * "createDir": true, - * "removeDir": true, - * "removeFile": true, - * "renameFile": true, - * "metadata": true, - * "exists": true - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. - * * ## Security * * This module prevents path traversal, not allowing absolute paths or parent dir components @@ -45,11 +19,9 @@ * *databases* folder of the {@link path.appDataDir | $APPDATA directory}: * ```json * { - * "tauri": { - * "allowlist": { - * "fs": { - * "scope": ["$APPDATA/databases/*"] - * } + * "plugins": { + * "fs": { + * "scope": ["$APPDATA/databases/*"] * } * } * } diff --git a/plugins/fs/src/scope.rs b/plugins/fs/src/scope.rs index c8958f2e..609506fc 100644 --- a/plugins/fs/src/scope.rs +++ b/plugins/fs/src/scope.rs @@ -80,7 +80,7 @@ fn push_pattern, F: Fn(&str) -> Result>( manager: &M, scope: &FsScope, diff --git a/plugins/global-shortcut/guest-js/index.ts b/plugins/global-shortcut/guest-js/index.ts index f8686cff..ea105f25 100644 --- a/plugins/global-shortcut/guest-js/index.ts +++ b/plugins/global-shortcut/guest-js/index.ts @@ -5,19 +5,6 @@ /** * Register global shortcuts. * - * The APIs must be added to [`tauri.allowlist.globalShortcut`](https://tauri.app/v1/api/config/#allowlistconfig.globalshortcut) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "globalShortcut": { - * "all": true // enable all global shortcut APIs - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. * @module */ diff --git a/plugins/http/guest-js/index.ts b/plugins/http/guest-js/index.ts index 4f542b86..f2a8e2b2 100644 --- a/plugins/http/guest-js/index.ts +++ b/plugins/http/guest-js/index.ts @@ -5,21 +5,6 @@ /** * Access the HTTP client written in Rust. * - * The APIs must be allowlisted on `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "http": { - * "all": true, // enable all http APIs - * "request": true // enable HTTP request API - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. - * * ## Security * * This API has a scope configuration that forces you to restrict the URLs and paths that can be accessed using glob patterns. @@ -27,11 +12,9 @@ * For instance, this scope configuration only allows making HTTP requests to the GitHub API for the `tauri-apps` organization: * ```json * { - * "tauri": { - * "allowlist": { - * "http": { - * "scope": ["https://api.github.com/repos/tauri-apps/*"] - * } + * "plugins": { + * "http": { + * "scope": ["https://api.github.com/repos/tauri-apps/*"] * } * } * } @@ -105,7 +88,7 @@ class Body { * By default it sets the `application/x-www-form-urlencoded` Content-Type header, * but you can set it to `multipart/form-data` if the Cargo feature `multipart` is enabled. * - * Note that a file path must be allowed in the `fs` allowlist scope. + * Note that a file path must be allowed in the `fs` scope. * @example * ```typescript * import { Body } from "@tauri-apps/plugin-http" diff --git a/plugins/http/src/scope.rs b/plugins/http/src/scope.rs index 0c620a9b..1b802ace 100644 --- a/plugins/http/src/scope.rs +++ b/plugins/http/src/scope.rs @@ -13,7 +13,7 @@ pub struct Scope { } impl Scope { - /// Creates a new scope from the allowlist's `http` scope configuration. + /// Creates a new scope from the scope configuration. pub(crate) fn new(scope: &HttpAllowlistScope) -> Self { Self { allowed_urls: scope diff --git a/plugins/notification/guest-js/index.ts b/plugins/notification/guest-js/index.ts index b11127eb..ee157ecc 100644 --- a/plugins/notification/guest-js/index.ts +++ b/plugins/notification/guest-js/index.ts @@ -6,21 +6,6 @@ * Send toast notifications (brief auto-expiring OS window element) to your user. * Can also be used with the Notification Web API. * - * This package is also accessible with `window.__TAURI__.notification` when [`build.withGlobalTauri`](https://tauri.app/v1/api/config/#buildconfig.withglobaltauri) in `tauri.conf.json` is set to `true`. - * - * The APIs must be added to [`tauri.allowlist.notification`](https://tauri.app/v1/api/config/#allowlistconfig.notification) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "notification": { - * "all": true // enable all notification APIs - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. * @module */ diff --git a/plugins/os/guest-js/index.ts b/plugins/os/guest-js/index.ts index 93147c0a..36c508f1 100644 --- a/plugins/os/guest-js/index.ts +++ b/plugins/os/guest-js/index.ts @@ -5,19 +5,6 @@ /** * Provides operating system-related utility methods and properties. * - * The APIs must be added to [`tauri.allowlist.os`](https://tauri.app/v1/api/config/#allowlistconfig.os) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "os": { - * "all": true, // enable all Os APIs - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. * @module */ diff --git a/plugins/shell/guest-js/index.ts b/plugins/shell/guest-js/index.ts index 979f51d1..9d5abb21 100644 --- a/plugins/shell/guest-js/index.ts +++ b/plugins/shell/guest-js/index.ts @@ -6,36 +6,19 @@ * Access the system shell. * Allows you to spawn child processes and manage files and URLs using their default application. * - * The APIs must be added to [`tauri.allowlist.shell`](https://tauri.app/v1/api/config/#allowlistconfig.shell) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "shell": { - * "all": true, // enable all shell APIs - * "execute": true, // enable process spawn APIs - * "sidecar": true, // enable spawning sidecars - * "open": true // enable opening files/URLs using the default program - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. - * * ## Security * * This API has a scope configuration that forces you to restrict the programs and arguments that can be used. * * ### Restricting access to the {@link open | `open`} API * - * On the allowlist, `open: true` means that the {@link open} API can be used with any URL, + * On the configuration object, `open: true` means that the {@link open} API can be used with any URL, * as the argument is validated with the `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+` regex. * You can change that regex by changing the boolean value to a string, e.g. `open: ^https://github.com/`. * * ### Restricting access to the {@link Command | `Command`} APIs * - * The `shell` allowlist object has a `scope` field that defines an array of CLIs that can be used. + * The plugin configuration object has a `scope` field that defines an array of CLIs that can be used. * Each CLI is a configuration object `{ name: string, cmd: string, sidecar?: bool, args?: boolean | Arg[] }`. * * - `name`: the unique identifier of the command, passed to the {@link Command.create | Command.create function}. @@ -55,13 +38,17 @@ * Configuration: * ```json * { - * "scope": [ - * { - * "name": "run-git-commit", - * "cmd": "git", - * "args": ["commit", "-m", { "validator": "\\S+" }] + * "plugins": { + * "shell": { + * "scope": [ + * { + * "name": "run-git-commit", + * "cmd": "git", + * "args": ["commit", "-m", { "validator": "\\S+" }] + * } + * ] * } - * ] + * } * } * ``` * Usage: @@ -425,7 +412,7 @@ class Command extends EventEmitter { * Creates a new `Command` instance. * * @param program The program name to execute. - * It must be configured on `tauri.conf.json > tauri > allowlist > shell > scope`. + * It must be configured on `tauri.conf.json > plugins > shell > scope`. * @param args Program arguments. * @param options Spawn options. */ @@ -462,7 +449,7 @@ class Command extends EventEmitter { * ``` * * @param program The program to execute. - * It must be configured on `tauri.conf.json > tauri > allowlist > shell > scope`. + * It must be configured on `tauri.conf.json > plugins > shell > scope`. */ static create( program: string, @@ -494,7 +481,7 @@ class Command extends EventEmitter { * ``` * * @param program The program to execute. - * It must be configured on `tauri.conf.json > tauri > allowlist > shell > scope`. + * It must be configured on `tauri.conf.json > plugins > shell > scope`. */ static sidecar( program: string, @@ -634,7 +621,7 @@ type CommandEvent = * ``` * * @param path The path or URL to open. - * This value is matched against the string regex defined on `tauri.conf.json > tauri > allowlist > shell > open`, + * This value is matched against the string regex defined on `tauri.conf.json > plugins > shell > open`, * which defaults to `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+`. * @param openWith The app to open the file or URL with. * Defaults to the system default application for the specified path type. diff --git a/plugins/shell/src/config.rs b/plugins/shell/src/config.rs index 1a35df4e..180de7f6 100644 --- a/plugins/shell/src/config.rs +++ b/plugins/shell/src/config.rs @@ -2,9 +2,7 @@ use std::path::PathBuf; use serde::{de::Error as DeError, Deserialize, Deserializer}; -/// Allowlist for the shell APIs. -/// -/// See more: https://tauri.app/v1/api/config#shellallowlistconfig +/// Configuration for the shell plugin. #[derive(Debug, Default, PartialEq, Eq, Clone, Deserialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct Config { diff --git a/plugins/shell/src/open.rs b/plugins/shell/src/open.rs index 5cc50927..a46d3f14 100644 --- a/plugins/shell/src/open.rs +++ b/plugins/shell/src/open.rs @@ -104,7 +104,7 @@ impl Program { /// Opens path or URL with the program specified in `with`, or system default if `None`. /// /// The path will be matched against the shell open validation regex, defaulting to `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+`. -/// A custom validation regex may be supplied in the config in `tauri > allowlist > scope > open`. +/// A custom validation regex may be supplied in the config in `plugins > shell > scope > open`. /// /// # Examples /// diff --git a/plugins/shell/src/scope.rs b/plugins/shell/src/scope.rs index 871f3940..67ebde6a 100644 --- a/plugins/shell/src/scope.rs +++ b/plugins/shell/src/scope.rs @@ -248,7 +248,7 @@ impl Scope { /// Open a path in the default (or specified) browser. /// - /// The path is validated against the `tauri > allowlist > shell > open` validation regex, which + /// The path is validated against the `plugins > shell > open` validation regex, which /// defaults to `^((mailto:\w+)|(tel:\w+)|(https?://\w+)).+`. pub fn open(&self, path: &str, with: Option) -> Result<(), Error> { // ensure we pass validation if the configuration has one diff --git a/plugins/window/guest-js/index.ts b/plugins/window/guest-js/index.ts index b330314b..afe5bc0f 100644 --- a/plugins/window/guest-js/index.ts +++ b/plugins/window/guest-js/index.ts @@ -5,51 +5,6 @@ /** * Provides APIs to create windows, communicate with other windows and manipulate the current window. * - * The APIs must be added to [`tauri.allowlist.window`](https://tauri.app/v1/api/config/#allowlistconfig.window) in `tauri.conf.json`: - * ```json - * { - * "tauri": { - * "allowlist": { - * "window": { - * "all": true, // enable all window APIs - * "create": true, // enable window creation - * "center": true, - * "requestUserAttention": true, - * "setResizable": true, - * "setTitle": true, - * "maximize": true, - * "unmaximize": true, - * "minimize": true, - * "unminimize": true, - * "show": true, - * "hide": true, - * "close": true, - * "setDecorations": true, - * "setShadow": true, - * "setAlwaysOnTop": true, - * "setContentProtected": true, - * "setSize": true, - * "setMinSize": true, - * "setMaxSize": true, - * "setPosition": true, - * "setFullscreen": true, - * "setFocus": true, - * "setIcon": true, - * "setSkipTaskbar": true, - * "setCursorGrab": true, - * "setCursorVisible": true, - * "setCursorIcon": true, - * "setCursorPosition": true, - * "setIgnoreCursorEvents": true, - * "startDragging": true, - * "print": true - * } - * } - * } - * } - * ``` - * It is recommended to allowlist only the APIs you use for optimal bundle size and security. - * * ## Window events * * Events can be listened to using `appWindow.listen`: @@ -1017,12 +972,12 @@ class WindowManager extends WebviewWindowHandle { label: this.label, value: size ? { - type: size.type, - data: { - width: size.width, - height: size.height, - }, - } + type: size.type, + data: { + width: size.width, + height: size.height, + }, + } : null, }); } @@ -1051,12 +1006,12 @@ class WindowManager extends WebviewWindowHandle { label: this.label, value: size ? { - type: size.type, - data: { - width: size.width, - height: size.height, - }, - } + type: size.type, + data: { + width: size.width, + height: size.height, + }, + } : null, }); } @@ -1831,11 +1786,11 @@ function mapMonitor(m: Monitor | null): Monitor | null { return m === null ? null : { - name: m.name, - scaleFactor: m.scaleFactor, - position: mapPhysicalPosition(m.position), - size: mapPhysicalSize(m.size), - }; + name: m.name, + scaleFactor: m.scaleFactor, + position: mapPhysicalPosition(m.position), + size: mapPhysicalSize(m.size), + }; } function mapPhysicalPosition(m: PhysicalPosition): PhysicalPosition {