Documentation: Chrome Permissions API
A promise-based wrapper for the Chrome permissions API to request and manage extension permissions.
- isAvailablePermissions()
- containsPermissions(permissions)
- getAllPermissions()
- requestPermissions(permissions)
- removePermissions(permissions)
- addHostAccessRequest(request?)
- removeHostAccessRequest(request?)
isAvailablePermissions(method?: ApiMethodName<typeof chrome.permissions>): booleanThe optional method is a native function name, for example isAvailablePermissions("contains").
Import the public ApiMethodName type from @addon-core/browser for your own typed helpers.
This checks callable presence without invoking the method; permissions and argument support still require handling.
Returns true when the permissions namespace is present on the API selected by browser() in the current context.
Returns false if the namespace or WebExtension environment is absent, or if accessing it throws.
The check is synchronous, does not log, and reads the current API on every call without caching.
Without an argument, it checks namespace presence only. Pass a native method name to also check that it is callable.
Neither form verifies permissions, argument support, or a successful operation. See method availability.
import {isAvailablePermissions} from "@addon-core/browser";
if (isAvailablePermissions()) {
// The namespace is present; handle operation-specific failures when using it.
}containsPermissions(permissions: chrome.permissions.Permissions): Promise<boolean>
Checks whether the extension has the specified permissions.
getAllPermissions(): Promise<chrome.permissions.Permissions>
Retrieves all granted permissions.
requestPermissions(permissions: chrome.permissions.Permissions): Promise<boolean>
Prompts the user to grant additional permissions.
removePermissions(permissions: chrome.permissions.Permissions): Promise<boolean>
Removes the specified permissions if granted.
addHostAccessRequest(request?: chrome.permissions.AddHostAccessRequest): Promise<void>
Requests additional host access at runtime.
removeHostAccessRequest(request?: chrome.permissions.RemoveHostAccessRequest): Promise<void>
Clears a previously requested host access.
onPermissionsAdded(callback: (permissions: chrome.permissions.Permissions) => void): () => void
Fires when new permissions are granted.
onPermissionsRemoved(callback: (permissions: chrome.permissions.Permissions) => void): () => void
Fires when permissions are removed.