@untemps/user-permissions-utils
v1.1.24
Published
Collection of utility functions to manage user permissions
Downloads
292
Readme
@untemps/user-permissions-utils
Collection of utility functions to manage user permissions.
Installation
yarn add @untemps/user-permissions-utils
Utils
getPermission
:
Returns a promise resolved when the permission is granted
import { getPermission } from '@untemps/user-permissions-utils'
const init = async () => {
try {
await getPermission('microphone')
...
} catch (error) {
console.error(error)
}
}
getUserMediaStream
:
Returns a promise resolved when the permission is granted and the stream is retrieved
import { getUserMediaStream } from '@untemps/user-permissions-utils'
const init = async () => {
try {
const stream = await getUserMediaStream('microphone', { audio: true })
if(!!stream) {
const audioContext = new AudioContext()
const streamNode = audioContext.createMediaStreamSource(stream)
...
} else {
console.error('Stream is not available')
}
} catch (error) {
console.error(error)
}
}
Todos
- Add permissions-based API:
- clipboard
- geolocation
- notification
- ...
- Add commitlint to ensure commit logs are valid