Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
fake-mediastreamtrack
Advanced tools
Fake W3C MediaStreamTrack implementation. Suitable for for Node.js or testing.
This library is intended for Node.js applications or libraries that depend on the MediaStreamTrack
class. The exposed FakeMediaStreamTrack
class does not internally manage any audio/video source.
This library provides TypeScript definitions and the FakeMediaStreamTrack
extendes the MediaStreamTrack
interface, so it can be safely used in any code requiring a MediaStreamTrack
object.
$ npm install fake-mediastreamtrack
const { FakeMediaStreamTrack } = require('fake-mediastreamtrack');
// or
import { FakeMediaStreamTrack } from 'fake-mediastreamtrack';
const track = new FakeMediaStreamTrack({ kind: 'audio' });
track.enabled = false;
console.log(
'track.readyState: %s, track.enabled: %s', track.readyState, track.enabled
);
// => 'track.readyState: live, track.enabled: false'
const clonedTrack = track.clone();
track.stop();
console.log('track.readyState: %s', track.readyState);
// => 'track.readyState: ended'
console.log('clonedTrack.readyState: %s', clonedTrack.readyState);
// => 'clonedTrack.readyState: live'
clonedTrack.applyConstraints({ frameRate: { max: 30, ideal: 20 } });
console.log('clonedTrack.getConstraints(): %o', clonedTrack.getConstraints());
// => clonedTrack.getConstraints(): { frameRate: { max: 30, ideal: 20 } }
The FakeMediaStreamTrack
class constructor accepts an object with the following fields.
const track = new FakeMediaStreamTrack({ kind, id, label, isolated, muted, data })
kind
(string, mandatory): "audio" or "video".id
(string, optional): Track unique identificator. If not given, a random one is generated.label
(string, optional): Track label. Defaults to empty string.isolated
(boolean, optional): See the spec. Defaults to false
.muted
(boolean, optional): Whether this track belongs to a muted source. Defaults to false
.data
(object, options): An object with custom application data.track.data
getter returns custom application data
object. The app can write into it at any time.track.enabled = flag
setter fires a proprietary "@enabledchange" event if the enabled
property changed.track.stop()
will fire a proprietary "@stop" event if not already stopped.track.remoteStop()
emulates a stop generated remotely. It will fired a proprietary "@stop" event and "ended" event if not already stopped.track.remoteMute()
emulates a mute generated remotely. It will fired "mute" event if not already muted.track.remoteUnmute()
emulates a unmute generated remotely. It will fired "unmute" event if not already unmuted.const { FakeMediaStreamTrack } = require('fake-mediastreamtrack');
const track = new FakeMediaStreamTrack({ kind: 'video' });
track.onended = () => console.log('track ended (1)');
track.addEventListener('ended', () => console.log('track ended (2)'));
track.addEventListener('@enabledchange', () => {
console.log('track enabled changed:', track.enabled);
});
track.enabled = false;
track.enabled = false;
track.enabled = true;
track.remoteStop();
// => track enabled changed: false
// => track enabled changed: true
// => track ended (1)
// => track ended (2)
Some W3C MediaStreamTrack properties and methods are not implemented:
track.getCapabilities()
track.getSettings()
track.onisolationchange
track.onoverconstrained
ISC
FAQs
Fake W3C MediaStreamTrack implementation
We found that fake-mediastreamtrack demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.