Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Configuration mixin for constructors.
facet
is available on npm.
$ npm install facet
facet
is available as a component.
$ component install qualiancy/facet
This mixin provides a way to store arbitray key/value pairs on a constructor or object. Furthermore, it provides a number of helper methods to retrieve the stored values.
Begin by applying the mixin to a constructor or object.
// on a constructor
facet(MyConstructor.prototype);
// on an object
var obj = {};
facet(obj);
Storage: Facet will default to creating and using the .settings
object on the constructor or object to store the
key/value pairs. If you would like to use something else
you may specify a different storage key.
facet(MyConstructor.prototype, '_options');
Handle: Facet can also invoke a handle anytime a setting is
written. This is preferred method of responding to
writes as opposed to overwriting the .set
method.
The this
context in the handle will be the object
instance.
facet(MyEventEmitter.prototype, function (key, value) {
// emit changes on self
this.emit('settings', key, value);
});
var ee = new MyEventEmitter();
ee.on('settings', function (key, value) {
console.log('%s was set to: ', key, value);
});
ee.set('hello', 'universe');
// "hello was set to: universe"
All Settings: If you are changing more than one of the options than you can use an object as the second argument.
store
handle
facet(MyEventEmitter.prototype, {
store: '_options'
, handle: function (key, value) {
this.emit('options', key, value);
}
});
Modify a key/value pair of settings, or use an object to modify many settings at once.
obj
.set('hello', 'universe')
.set({
hello: 'universe'
, say: 'loudly'
});
Return the value of a stored setting.
obj.get('hello').should.equal('universe');
Mark a setting key as "enabled" (true).
obj.enable('loudly');
Mark a setting key as "disabled" (false).
obj.disable('whisper');
Confirm that a given key is enabled (=== true).
Settings that do not exist will return false
.
obj.enabled('loudly').should.be.true;
obj.enabled('whisper').should.be.false;
obj.enabled('scream').should.be.false;
Confirm that a setting key is disabled (=== false).
Settings that do not exists will return true
.
obj.disabled('loudly').should.be.false;
obj.disabled('whisper').should.be.true;
obj.disabled('scream').should.be.true;
(The MIT License)
Copyright (c) 2012 Jake Luer jake@qualiancy.com (http://qualiancy.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Configuration mixin for constructors.
The npm package facet receives a total of 0 weekly downloads. As such, facet popularity was classified as not popular.
We found that facet 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.