https://github.com/clebert/node-d-bus
A Node.js implementation of D-Bus with native TypeScript support.
https://github.com/clebert/node-d-bus
Last synced: over 1 year ago
JSON representation
A Node.js implementation of D-Bus with native TypeScript support.
- Host: GitHub
- URL: https://github.com/clebert/node-d-bus
- Owner: clebert
- License: mit
- Created: 2021-04-20T13:23:34.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-11-12T09:33:46.000Z (over 2 years ago)
- Last Synced: 2025-02-23T05:35:25.886Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 153 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Node.js D-Bus
> A Node.js implementation of D-Bus with native TypeScript support.
## Installation
```
npm install @clebert/node-d-bus d-bus-message-protocol d-bus-type-system
```
## Features
- Designed from the ground up with TypeScript.
- Depends only on
[d-bus-message-protocol](https://github.com/clebert/d-bus-message-protocol)
and [d-bus-type-system](https://github.com/clebert/d-bus-type-system).
- Built-in support for the system message bus connected via Unix domain socket
path.
- The default path (`unix:path=/var/run/dbus/system_bus_socket`) can be
overwritten with the environment variable `DBUS_SYSTEM_BUS_ADDRESS`.
- Built-in support for authentication as external.
## Usage example
### Call the `org.freedesktop.DBus.Hello` method
```js
import {SystemDBus} from '@clebert/node-d-bus';
import {MessageType} from 'd-bus-message-protocol';
const dBus = new SystemDBus();
await dBus.connectAsExternal();
try {
const helloReturnMessage = await dBus.callMethod({
messageType: MessageType.MethodCall,
objectPath: `/org/freedesktop/DBus`,
interfaceName: `org.freedesktop.DBus`,
memberName: `Hello`,
serial: dBus.nextSerial,
destination: `org.freedesktop.DBus`,
});
console.log(JSON.stringify(helloReturnMessage));
} finally {
dBus.disconnect();
}
```
```json
{
"messageType": 2,
"replySerial": 1,
"serial": 1,
"noReplyExpected": true,
"noAutoStart": false,
"allowInteractiveAuthorization": false,
"destination": ":1.811",
"sender": "org.freedesktop.DBus",
"type": {"typeCode": "s", "bytePadding": 4},
"body": ":1.811"
}
```
Note: The preceding message can also be conveniently sent using the
`await dBus.hello()` method.