mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-11-24 12:14:05 +03:00
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
5
.changes/api-permissions-plugin.md
Normal file
5
.changes/api-permissions-plugin.md
Normal file
@ -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.
|
* Command arguments.
|
||||||
*
|
*
|
||||||
@ -249,6 +269,9 @@ export {
|
|||||||
Channel,
|
Channel,
|
||||||
PluginListener,
|
PluginListener,
|
||||||
addPluginListener,
|
addPluginListener,
|
||||||
|
PermissionState,
|
||||||
|
checkPermissions,
|
||||||
|
requestPermissions,
|
||||||
invoke,
|
invoke,
|
||||||
convertFileSrc,
|
convertFileSrc,
|
||||||
isTauri
|
isTauri
|
||||||
|
Loading…
Reference in New Issue
Block a user