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.
Fusing is a small library that creates the base class that is used in all of bigpipe's components. It takes care of:
readable
and writable
properties to these classes.Backbone.extend
based extending of the prototypes.The stable versions of this module are released in the npm registry and can be installed using:
npm install --save fusing
The --save
tells npm
to automatically save this dependency in your
package.json
.
The module is required just like any other module you use. It exposes a single function that takes care of all the merging.
'use strict';
var fuse = require('fusing');
And that is all we need to start with inheritance. When you want to have a class
inherit from the EventEmitter
you only need to pass in the class references:
function Example() {
}
fuse(Example, require('events').EventEmitter);
This will tell fuse
to use the .prototype
of the EventEmitter
for your
Example
class. In addition to that it has added a couple of function to your
class which makes it easier to setup the prototypes and extend Example again.
One of the functions that are added to your class is readable
this allows you
to easily specify which properties or methods on the Example.prototype
are
read-only
and should never be overridden by other code. This is ideal for
protecting your private methods.
Example.readable('config', { foo: 'bar' });
The example above added the property config
to the prototype with the foo/bar
object as value. If you wonder how this magic works, take a look a our
predefine project for more details.
Please note that this function is added on the Example
function not on the
Example.prototype
.
This is the writable equivalent of the function above. This allows you to
specify properties on the prototype that are writable. The added benefit of this
function is that your methods will not be enumerable (which is also true for all
properties/methods added using the readable
function).
Example.writable('property', 'foo');
Please note that this function is added on the Example
function not on the
Example.prototype
.
Add a getter to the prototype.
var foo = 'bar'
Example.get('property', function () {
return foo;
});
Please note that this function is added on the Example
function not on the
Example.prototype
.
Add a getter AND a setter to the prototype.
var foo = 'bar'
Example.set('property', function () {
return foo;
}, function (value) {
return foo = value;
});
Please note that this function is added on the Example
function not on the
Example.prototype
.
This allows you to use the same extend
functionality that you might be
accustomed to with Backbone
in your own classes:
var MyExample = Example.extend({
method: function method() {
console.log('my custom method');
},
prop: 132
});
Please note that this function is added on the Example
function not on the
Example.prototype
.
As it's sometimes useful to also create readable and writable properties when
your class is constructed, we decided to expose the predefine
module on your
class. Which allows you use the same readable pattern again:
function Example() {
var writable = Example.predefine(this, Example.predefine.WRITABLE)
, readable = Example.predefine(this);
readable('private', 134);
readable('evn', process.ENV.NODE_ENV || 'development');
writable('value', 100);
}
fuse(Example, require('eventemitter3'));
Please note that this function is added on the Example
function not on the
Example.prototype
.
MIT
FAQs
Prototype fusion
The npm package fusing receives a total of 29,894 weekly downloads. As such, fusing popularity was classified as popular.
We found that fusing demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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.