Socket
Socket
Sign inDemoInstall

@homebridge/dbus-native

Package Overview
Dependencies
Maintainers
8
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@homebridge/dbus-native - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

15

bin/dbus2js.js

@@ -5,7 +5,12 @@ #!/usr/bin/env node

const xml2js = require('xml2js');
const xml2js_opts = Object.assign({}, xml2js.defaults["0.1"], { explicitArray: true });
const xml2js_opts = Object.assign({}, xml2js.defaults['0.1'], {
explicitArray: true
});
const dbus = require('../index');
const optimist = require('optimist');
const minimist = require('minimist');
var argv = optimist.boolean(['server', 'dump']).argv;
var argv = minimist(process.argv.slice(2), {
boolean: ['server', 'dump', 'xml'],
string: ['bus', 'service', 'path']
});

@@ -69,5 +74,3 @@ function die(err) {

output.push(
` var signalFullName = bus.mangle('${argv.path}', '${
ifaceName
}', signame);`
` var signalFullName = bus.mangle('${argv.path}', '${ifaceName}', signame);`
);

@@ -74,0 +77,0 @@ output.push(

4

lib/address-x11.js

@@ -14,5 +14,3 @@ // read dbus adress from window selection

var X = display.client;
var selectionName = `_DBUS_SESSION_BUS_SELECTION_${
hostname
}_${uuid.trim()}`;
var selectionName = `_DBUS_SESSION_BUS_SELECTION_${hostname}_${uuid.trim()}`;
X.InternAtom(false, selectionName, function(err, id) {

@@ -19,0 +17,0 @@ if (err) return callback(err);

const Buffer = require('safe-buffer').Buffer;
function align(ps, n) {
var pad = n - ps._offset % n;
var pad = n - (ps._offset % n);
if (pad === 0 || pad === n) return;

@@ -6,0 +6,0 @@ // TODO: write8(0) in a loop (3 to 7 times here) could be more efficient

@@ -161,5 +161,3 @@ const EventEmitter = require('events').EventEmitter;

'org.freedesktop.DBus.Error.UnknownMethod',
`Method "${msg.member}" on interface "${
msg.interface
}" doesn't exist`
`Method "${msg.member}" on interface "${msg.interface}" doesn't exist`
);

@@ -166,0 +164,0 @@ return;

@@ -35,2 +35,3 @@ const Buffer = require('safe-buffer').Buffer;

);
// eslint-disable-next-line no-prototype-builtins
if (process.hasOwnProperty('getuid') && stat.uid !== process.getuid())

@@ -76,2 +77,3 @@ return cb(

var authMethod = methods.shift();
// eslint-disable-next-line no-prototype-builtins
var uid = process.hasOwnProperty('getuid') ? process.getuid() : 0;

@@ -78,0 +80,0 @@ var id = hexlify(uid);

@@ -12,3 +12,5 @@ const xml2js = require('xml2js');

},
function(err, xml) { module.exports.processXML(err, xml, obj, callback); }
function(err, xml) {
module.exports.processXML(err, xml, obj, callback);
}
);

@@ -63,3 +65,7 @@ };

property = iface.property[p];
currentIface.$createProp(property['$'].name, property['$'].type, property['$'].access)
currentIface.$createProp(
property['$'].name,
property['$'].type,
property['$'].access
);
}

@@ -70,7 +76,5 @@ // TODO: introspect signals

});
}
};
function DBusInterface(parent_obj, ifname)
{
function DBusInterface(parent_obj, ifname) {
// Since methods and props presently get added directly to the object, to avoid collision with existing names we must use $ naming convention as $ is invalid for dbus member names

@@ -95,4 +99,7 @@ // https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names

return this.$sigHandlers[index];
}
DBusInterface.prototype.addListener = DBusInterface.prototype.on = function(signame, callback) {
};
DBusInterface.prototype.addListener = DBusInterface.prototype.on = function(
signame,
callback
) {
// http://dbus.freedesktop.org/doc/api/html/group__DBusBus.html#ga4eb6401ba014da3dbe3dc4e2a8e5b3ef

@@ -105,6 +112,9 @@ // An example is "type='signal',sender='org.freedesktop.DBus', interface='org.freedesktop.DBus',member='Foo', path='/bar/foo',destination=':452345.34'" ...

var match = getMatchRule(this.$parent.name, this.$name, signame);
bus.addMatch(match, function(err) {
if (err) throw new Error(err);
bus.signals.on(signalFullName, this.$getSigHandler(callback));
}.bind(this));
bus.addMatch(
match,
function(err) {
if (err) throw new Error(err);
bus.signals.on(signalFullName, this.$getSigHandler(callback));
}.bind(this)
);
} else {

@@ -114,31 +124,35 @@ // The match is already there, just add event listener

}
}
DBusInterface.prototype.removeListener = DBusInterface.prototype.off = function(signame, callback) {
};
DBusInterface.prototype.removeListener = DBusInterface.prototype.off = function(
signame,
callback
) {
var bus = this.$parent.service.bus;
var signalFullName = bus.mangle(this.$parent.name, this.$name, signame);
bus.signals.removeListener( signalFullName, this.$getSigHandler(callback) );
bus.signals.removeListener(signalFullName, this.$getSigHandler(callback));
if (!bus.signals.listeners(signalFullName).length) {
// There is no event handlers for this match
var match = getMatchRule(this.$parent.name, this.$name, signame);
bus.removeMatch(match, function(err) {
if (err) throw new Error(err);
// Now it is safe to empty these arrays
this.$callbacks.length = 0;
this.$sigHandlers.length = 0;
}.bind(this));
bus.removeMatch(
match,
function(err) {
if (err) throw new Error(err);
// Now it is safe to empty these arrays
this.$callbacks.length = 0;
this.$sigHandlers.length = 0;
}.bind(this)
);
}
}
DBusInterface.prototype.$createMethod = function(mName, signature)
{
};
DBusInterface.prototype.$createMethod = function(mName, signature) {
this.$methods[mName] = signature;
this[mName] = function() { this.$callMethod(mName, arguments); }
}
DBusInterface.prototype.$callMethod = function(mName, args)
{
this[mName] = function() {
this.$callMethod(mName, arguments);
};
};
DBusInterface.prototype.$callMethod = function(mName, args) {
var bus = this.$parent.service.bus;
if (!Array.isArray(args)) args = Array.from(args); // Array.prototype.slice.apply(args)
var callback =
typeof args[args.length - 1] === 'function'
? args.pop()
: function() {};
typeof args[args.length - 1] === 'function' ? args.pop() : function() {};
var msg = {

@@ -155,5 +169,4 @@ destination: this.$parent.service.name,

bus.invoke(msg, callback);
}
DBusInterface.prototype.$createProp = function(propName, propType, propAccess)
{
};
DBusInterface.prototype.$createProp = function(propName, propType, propAccess) {
this.$properties[propName] = { type: propType, access: propAccess };

@@ -163,7 +176,8 @@ Object.defineProperty(this, propName, {

get: () => callback => this.$readProp(propName, callback),
set: function(val) { this.$writeProp(propName, val) }
set: function(val) {
this.$writeProp(propName, val);
}
});
}
DBusInterface.prototype.$readProp = function(propName, callback)
{
};
DBusInterface.prototype.$readProp = function(propName, callback) {
var bus = this.$parent.service.bus;

@@ -192,5 +206,4 @@ bus.invoke(

);
}
DBusInterface.prototype.$writeProp = function(propName, val)
{
};
DBusInterface.prototype.$writeProp = function(propName, val) {
var bus = this.$parent.service.bus;

@@ -205,7 +218,6 @@ bus.invoke({

});
}
};
function getMatchRule(objName, ifName, signame) {
return `type='signal',path='${objName}',interface='${ifName}',member='${signame}'`;
}
const assert = require('assert');
const parseSignature = require('./signature');
const put = require('put');
const put = require('@homebridge/put');
const Marshallers = require('./marshallers');

@@ -6,0 +6,0 @@ const align = require('./align').align;

@@ -155,5 +155,5 @@ const constants = require('./constants');

result.push(
` <arg type="${dumpSignature([arg])}" name="${argName}${
dirStr
}" />`
` <arg type="${dumpSignature([
arg
])}" name="${argName}${dirStr}" />`
);

@@ -184,5 +184,3 @@ });

result.push(
` <property name="${propertyName}" type="${
iface.properties[propertyName]
}" access="readwrite"/>`
` <property name="${propertyName}" type="${iface.properties[propertyName]}" access="readwrite"/>`
);

@@ -189,0 +187,0 @@ }

{
"name": "@homebridge/dbus-native",
"author": "Andrey Sidorov <sidorares@yandex.com>",
"version": "0.4.1",
"version": "0.4.2",
"keywords": [

@@ -41,7 +41,7 @@ "dbus",

"dependencies": {
"@homebridge/long": "^5.2.1",
"event-stream": "^4.0.0",
"hexy": "^0.2.10",
"@homebridge/long": "^5.2.1",
"optimist": "^0.6.1",
"put": "0.0.6",
"minimist": "^1.2.6",
"@homebridge/put": "~0.0.8",
"safe-buffer": "^5.1.1",

@@ -56,9 +56,11 @@ "xml2js": "^0.4.17"

"devDependencies": {
"eslint": "^5.0.0",
"@types/minimist": "^1.2.2",
"eslint": "^6.0.0",
"eslint-config-prettier": "^3.0.0",
"eslint-plugin-markdown": "^1.0.0-beta.6",
"eslint-plugin-markdown": "^3.0.0",
"eslint-plugin-prettier": "^3.0.0",
"husky": "^1.0.0",
"lint-staged": "^8.0.0",
"lint-staged": "^13.0.3",
"mocha": "*",
"nyc": "^15.1.0",
"prettier": "^1.7.4"

@@ -65,0 +67,0 @@ },

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