Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
node-dbus is a D-Bus binding for Node.js.
$ npm install dbus
To build, do: node-gyp configure build
or npm install
.
The API changed between version 0.2.21 and version 1.0.0. See migrating for information on how to migrate your application to the new API.
Node-gyp
$ npm install -g node-gyp
libdbus
$ sudo apt-get install libdbus-1-dev
or equivalent for your system
glib2.0
$ sudo apt-get install libglib2.0-dev
or equivalent for your system
Node-gyp
$ npm install -g node-gyp
libdbus
MacPorts: $ sudo port install pkg-config dbus
HomeBrew: $ sudo brew install pkg-config dbus
glib2.0
MacPorts: $ sudo port install glib2
HomeBrew: $ sudo brew install glib
Best way to get started is by looking at the examples. After the build:
path/to/dbus/examples
foldernode service.js &
node hello.js
Work your way through other examples to explore supported functionality.
If no X server is running, the module fails when attempting to obtain a D-Bus
connection at DBus.getBus()
. This can be remedied by setting two environment
variables manually (the actual bus address might be different):
process.env.DISPLAY = ':0';
process.env.DBUS_SESSION_BUS_ADDRESS = 'unix:path=/run/dbus/system_bus_socket';
The root object of this module.
DBus.getBus(busName)
<string>
Connect to a bus. busName
must be either "system"
to connect to the system
bus or "session"
to connect to the session bus.
Returns a Bus
.
var bus = DBus.getBus('session');
DBus.registerService(busName, serviceName)
<string>
<string>
Register a service on a specific bus. This allows the caller to create a DBus service.
busName
must be either "system"
to create the service on the system bus, or
"session"
to create the service on the session bus. Note: the system bus
often has security requirements that need to be met before the service can be
registered.
Returns a Service
.
var service = DBus.registerService('session', 'com.example.Library');
new DBus()
Create a new DBus instance.
var DBus = require('dbus')
var dbus = new DBus()
DBus.prototype.getBus(busName)
Use DBus.getBus(busName)
.
DBus.prototype.registerService(busName, serviceName)
Use DBus.registerService(busName, serviceName)
An active connection to one of DBus' buses.
Bus.prototype.getInterface(serviceName, objectPath, interfaceName, callback)
<string>
- The well-known name of the service that owns the object.<string>
- The path of the object.<string>
- Which of the object's interfaces to retrieve.<function>
Get an existing object's interface from a well-known service.
Once retrieved, callback
will be called with either an error or with an
Interface
.
bus.getInterface('com.example.Library', '/com/example/Library/authors/DAdams', 'com.example.Library.Author1', function(err, interface) {
if (err) {
...
}
// Do something with the interface
});
Bus.prototype.disconnect()
Disconnect from DBus. This disconnection makes it so that Node isn't kept running based on this active connection. It also makes this bus, and all of its children (interfaces that have been retrieved, etc.) unusable.
Interface.prototype.getProperty(propertyName, callback)
<string>
- The name of the property to get.<function>
Get the value of a property.
Once retrieved callback
will be called with either an error or with the value
of the property.
interface.getProperty('Name', function(err, name) {
});
Interface.prototype.setProperty(propertyName, value, callback)
<string>
- The name of the property to get.<any>
- The value of the property to set.<function>
Set the value of a property.
Once set callback
will be called with either an error or nothing.
interface.setProperty('Name', 'Douglas Adams', function(err) {
});
Interface.prototype.getProperties(callback)
<function>
Get the value of all of the properties of the interface.
Once retrieved callback
will be called with either an error or with an object
where the keys are the names of the properties, and the values are the values
of those properties.
interface.getProperties(function(err, properties) {
console.log(properties.Name);
});
Interface.prototype[methodName](...args, [options], callback)
<string>
- The name of the method on the interface to call.<any>
- The arguments that must be passed to the method.<object>
- The options that can be set. This is optional.
<number>
- The number of milliseconds to wait before the
request is timed out. This defaults to -1
: don't time out.<function>
Call a method on the interface.
Once executed, callback
will be called with either an error or with the
result of the method call.
interface.AddBook("The Hitchhiker's Guide to the Galaxy", { timeout: 1000 }, function(err, result) {
})
A dbus service created by the application.
Service.prototype.createObject(objectPath)
<string>
- The path of the object. E.g., /com/example/ObjectName
Create an object that is exposed over DBus.
Returns a ServiceObject
.
var object = service.createObject('/com/example/Library/authors/DAdams');
Service.prototype.removeObject(object)
<ServiceObject>
- the service object that has been createdRemove (or unexpose) an object that has been created.
service.removeObject(object);
Service.prototype.disconnect()
Disconnect from DBus. This disconnection makes it so that Node isn't kept running based on this active connection. It also disconnects all of the objects created by this service.
An object that is exposed over DBus.
ServiceObject.prototype.createInterface(interfaceName)
<string>
- The name of the interface.Create an interface on an object.
Returns a ServiceInterface
.
var interface = object.createInterface('com.example.Library.Author1');
An interface for an object that is exposed over DBus.
ServiceInterface.prototype.addMethod(method, opts, handler)
<string>
- The name of the method<object>
- Options for the method
<function>
- The method handlerAdd a method that can be called over DBus.
interface.addMethod('AddBook', {
in: [DBus.Define(String), DBus.Define(Number)],
out: [DBus.Define(Number)]
}, function(name, quality, callback) {
doSomeAsyncOperation(name, quality, function(err, result) {
if (err) {
return callback(err);
}
callback(result);
});
});
ServiceInterface.prototype.addProperty(name, opts)
<string>
- The name of the property<object>
Add a property that can be get, and/or optionally set, over DBus.
interface.addProperty('BooksWritten', {
type: DBus.Define(Number),
getter: function(callback) {
getNumberOfBooksForAuthor(function(err, bookCount) {
if(err) {
return callback(err);
}
callback(bookCount);
});
}
}
var name = 'Douglas Adams';
interface.addProperty('Name', {
type: Dbus.Define(String),
getter: function(callback) {
callback(name);
}
setter: function(value, done) {
name = value;
done();
}
}
ServiceInterface.prototype.addSignal(name, opts)
<string>
- The name of the signal<object>
Create a DBus signal.
interface.addSignal('bookCreated', {
types: [DBus.Define(Object)]
});
ServiceInterface.prototype.emitSignal(name, ...values)
<string>
- The name of the signal<any>
- The values to emitEmit a signal
interface.emit('bookCreated', { name: "The Hitchhiker's Guide to the Galaxy" })
ServiceInterface.prototype.update()
Save interface updates after making changes. After changes to the interface are
made (via addMethod
, addProperty
, and addSignal
), update
must be called
to ensure that other DBus clients can see the changes that were made.
A DBus-specific error
new DBus.Error(name, message)
<string>
- A valid DBus Error name, according to the specification<string>
- A human readable messageCreate a new error. The name must be a valid error name.
throw new DBus.Error('com.example.Library.Error.BookExistsError', 'The book already exists');
dbusError.dbusName
The DBus Error name of the error. When a DBus.Error is created, its message is
set to the human-readable error message. The dbusName
property is set to the
name (according to the DBus Spec).
(The MIT License)
Copyright (c) 2013
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
A D-Bus binding for Node
The npm package dbus receives a total of 348 weekly downloads. As such, dbus popularity was classified as not popular.
We found that dbus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.