Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mic-check

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mic-check - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

4

lib/requestMediaPermissions.d.ts

@@ -20,2 +20,4 @@ export declare type MediaPermissionsError = {

*/
export declare const requestMediaPermissions: () => Promise<boolean>;
export declare const requestMediaPermissions: (constraints?: MediaStreamConstraints | undefined) => Promise<boolean>;
export declare const requestAudioPermissions: () => Promise<boolean>;
export declare const requestVideoPermissions: () => Promise<boolean>;

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.requestMediaPermissions = exports.MediaPermissionsErrorType = void 0;
exports.requestVideoPermissions = exports.requestAudioPermissions = exports.requestMediaPermissions = exports.MediaPermissionsErrorType = void 0;
const bowser_1 = __importDefault(require("bowser"));

@@ -24,7 +24,6 @@ var MediaPermissionsErrorType;

*/
const requestMediaPermissions = () => {
const requestMediaPermissions = (constraints) => {
return new Promise((resolve, reject) => {
let constraints = { audio: true, video: true };
navigator.mediaDevices
.getUserMedia(constraints)
.getUserMedia(constraints !== null && constraints !== void 0 ? constraints : { audio: true, video: true })
.then((stream) => {

@@ -39,6 +38,2 @@ stream.getTracks().forEach((t) => {

const browserName = browser.getBrowserName();
// console.log(browserName);
// console.log(err.name);
// console.log(err.message);
// console.log(browser);
const errName = err.name;

@@ -109,1 +104,5 @@ const errMessage = err.message;

exports.requestMediaPermissions = requestMediaPermissions;
const requestAudioPermissions = () => (0, exports.requestMediaPermissions)({ audio: true, video: false });
exports.requestAudioPermissions = requestAudioPermissions;
const requestVideoPermissions = () => (0, exports.requestMediaPermissions)({ audio: false, video: true });
exports.requestVideoPermissions = requestVideoPermissions;
{
"name": "mic-check",
"title": "mic-check",
"version": "1.0.0",
"description": "A wrapper for requesting audio and video permissions on websites.",
"version": "1.1.0",
"description": "A wrapper for requesting audio and video permissions on JavaScript websites.",
"main": "lib/index.js",

@@ -26,6 +26,5 @@ "module": "lib/index.js",

"react",
"permissions",
"camera",
"microphone"
"permissions"
],
"readmeFilename": "README.md",
"peerDependencies": {},

@@ -38,13 +37,3 @@ "devDependencies": {

"bowser": "^2.11.0"
},
"bugs": {
"url": "https://github.com/gtechnologies/mic-check/issues"
},
"homepage": "https://github.com/gtechnologies/mic-check#readme",
"directories": {
"example": "examples",
"lib": "lib"
},
"author": "",
"license": "ISC"
}
}

@@ -65,2 +65,35 @@ # mic-check

## Seperate audio/video permission
```ts
import {
MediaPermissionsError
MediaPermissionsErrorType,
requestAudioPermissions,
requestVideoPermissions,
requestMediaPermissions
} from 'mic-check';
// Requesting AUDIO permission only:
requestAudioPermissions()
.then(() => {})
.catch((err: MediaPermissionsError) => {});
// another way to request AUDIO only...
requestMediaPermissions({audio: true, video: false})
.then(() => {})
.catch((err: MediaPermissionsError) => {});
// Requesting VIDEO permission only:
requestVideoPermissions()
.then(() => {})
.catch((err: MediaPermissionsError) => {});
// another way to request VIDEO only...
requestMediaPermissions({audio: false, video: true})
.then(() => {})
.catch((err: MediaPermissionsError) => {});
```
## Documentation

@@ -103,3 +136,3 @@

<input type="checkbox" disabled /> Allow custom constraints for `getUserMedia()`.
<input type="checkbox" checked /> Allow custom constraints for `getUserMedia()`.

@@ -106,0 +139,0 @@ <input type="checkbox" disabled /> Handle errors for when there are no camera or microphone devices.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc