Merge branch 'master' into NTP-27557-ext-deprec
This commit is contained in:
@@ -3,6 +3,15 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
|
||||
## 1.3.1 (2025-01-30)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/common
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 1.2.6 (2025-01-29)
|
||||
|
||||
**Note:** Version bump only for package @universal-call-sdk/common
|
||||
|
||||
@@ -33,6 +33,7 @@ class IAdapter {
|
||||
return Promise.resolve(new Response());
|
||||
}
|
||||
transferCallToAgent(data: GenericObject) {console.log("transfer call", data)}
|
||||
checkAllPermissions():Promise<boolean> {return Promise.resolve(true)}
|
||||
}
|
||||
|
||||
export default IAdapter;
|
||||
|
||||
7
packages/common/lib/constants.ts
Normal file
7
packages/common/lib/constants.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export enum PermissionState {
|
||||
GRANTED = "granted",
|
||||
PROMPT = "prompt",
|
||||
DENIED = "denied"
|
||||
}
|
||||
|
||||
export const MICROPHONE = 'microphone' as PermissionName;
|
||||
37
packages/common/lib/utils/getPermissions.ts
Normal file
37
packages/common/lib/utils/getPermissions.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { MICROPHONE, PermissionState } from "../constants";
|
||||
|
||||
export const checkPermission = async (permissionName: PermissionName, mediaType: MediaStreamConstraints): Promise<boolean> => {
|
||||
try {
|
||||
if (!navigator.permissions) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const permission = await navigator.permissions.query({ name: permissionName });
|
||||
permission.onchange = () => {
|
||||
location.reload();
|
||||
};
|
||||
|
||||
switch (permission.state) {
|
||||
case PermissionState.GRANTED:
|
||||
return true;
|
||||
case PermissionState.PROMPT:
|
||||
await navigator.mediaDevices.getUserMedia(mediaType);
|
||||
return false;
|
||||
case PermissionState.DENIED:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export const checkMicrophonePermission = async (): Promise<boolean> => {
|
||||
return checkPermission(MICROPHONE, { audio: true });
|
||||
};
|
||||
|
||||
|
||||
export const checkAllPermissions = async (): Promise<boolean> => {
|
||||
return await checkMicrophonePermission();
|
||||
};
|
||||
Reference in New Issue
Block a user