mirror of https://github.com/tauri-apps/tauri
feat(api): permission types for mobile plugins (#10799)
* feat(api): permission types for mobile plugins let's have a central place to keep the permission types ref https://github.com/tauri-apps/plugins-workspace/issues/979 * build
This commit is contained in:
parent
d1c97bce7b
commit
f81929e251
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@tauri-apps/api": patch:enhance
|
||||
---
|
||||
|
||||
Added `PermissionState`, `checkPermissions` and `requestPermissions` base APIs to the core module, designed for plugin authors to extend.
|
File diff suppressed because one or more lines are too long
|
@ -123,6 +123,26 @@ async function addPluginListener<T>(
|
|||
)
|
||||
}
|
||||
|
||||
type PermissionState = 'granted' | 'denied' | 'prompt' | 'prompt-with-rationale'
|
||||
|
||||
/**
|
||||
* Get permission state for a plugin.
|
||||
*
|
||||
* This should be used by plugin authors to wrap their actual implementation.
|
||||
*/
|
||||
async function checkPermissions<T>(plugin: string): Promise<T> {
|
||||
return invoke(`plugin:${plugin}|check_permissions`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Request permissions.
|
||||
*
|
||||
* This should be used by plugin authors to wrap their actual implementation.
|
||||
*/
|
||||
async function requestPermissions<T>(plugin: string): Promise<T> {
|
||||
return invoke(`plugin:${plugin}|request_permissions`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Command arguments.
|
||||
*
|
||||
|
@ -249,6 +269,9 @@ export {
|
|||
Channel,
|
||||
PluginListener,
|
||||
addPluginListener,
|
||||
PermissionState,
|
||||
checkPermissions,
|
||||
requestPermissions,
|
||||
invoke,
|
||||
convertFileSrc,
|
||||
isTauri
|
||||
|
|
Loading…
Reference in New Issue