https://github.com/untemps/user-permissions-utils
Collection of utility functions to manage user permissions
https://github.com/untemps/user-permissions-utils
permissions utils
Last synced: 3 months ago
JSON representation
Collection of utility functions to manage user permissions
- Host: GitHub
- URL: https://github.com/untemps/user-permissions-utils
- Owner: untemps
- License: mit
- Created: 2020-06-23T13:55:55.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-13T17:39:22.000Z (6 months ago)
- Last Synced: 2025-02-14T07:04:15.649Z (4 months ago)
- Topics: permissions, utils
- Language: JavaScript
- Homepage:
- Size: 599 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @untemps/user-permissions-utils
Collection of utility functions to manage user permissions.

[](https://github.com/untemps/user-permissions-utils/actions)
## Installation
```bash
yarn add @untemps/user-permissions-utils
```## Utils
`getPermission`:
Returns a promise resolved when the permission is granted
```javascript
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
```javascript
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