
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A js node client for ZooKeeper
var ZK = require('zkjs')
var zk = new ZK({
hosts: ['localhost:2181', 'localhost:2182', 'localhost:2183'],
root: '/myapp/root'
})
zk.start(function (err) {
zk.create(
'/foo',
'some ephemeral data',
ZK.create.EPHEMERAL,
function (err, path) {
if (!err) {
console.log(path, 'was created')
}
}
)
zk.getChildren(
'/',
function (err, children, zstat) {
if (!err) {
console.log('/', 'has', children.length, 'children')
}
}
)
zk.get(
'/some/known/node',
function (watch) {
console.log(watch.path, 'was', watch.type)
},
function (err, value, zstat) {
console.log('the current value is ', value.toString())
zk.set(
'/some/known/node',
'some new data',
zstat.version,
function (err, zstat) {
if (!err) {
console.log('the new version number is', zstat.version)
}
}
)
}
)
})
var ZK = require('zkjs')
var zk = new ZK({
hosts: ['localhost:2181'], // array of zookeeper instances
root: '/', // the root path for the session
readOnly: false, // allow read-only connections
timeout: 120000, // requested timeout for the session
requestTimeout: 30000, // milliseconds before timing out a zk request
maxReconnectAttempts: 15, // number of attempts to re-establish a connection
retryPolicy: ZK.retry.no() // default retry policy
retryOn: ZK.errors.RETRY_DEFAULTS,// array of error codes to automatically retry
autoResetWatches: true, // maintain watches if the zookeeper instance changes
credentials: [] // array of credentials to auth the session with
logger: null // an object that implements the 'global.console' interface (for debugging)
})
Start a ZooKeeper session.
Arguments
err is defined the connection failed.Close the ZooKeeper session and it's connection
Create a new node
Arguments
ZK.create flagsFlags
ZK.create.NONE
ZK.create.EPHEMERAL
ZK.create.SEQUENCE
ZK.create.EPHEMERAL_SEQUENCE
Delete a node
Arguments
Checks whether a node exists
Arguments
Get the value of a node
Arguments
Get ACL information of a node
Arguments
Get the children of a node
Arguments
Create a path of nodes
Arguments
Set the value of a node
Arguments
Sets the ACL of a node
Arguments
Sync the node with the leader
Arguments
A string value of the session. For debugging.
Begin a ZooKeeper transaction. See Transactions
started
The session is ready to use... or not.
zk.on('started', function (err) {
if (err) {
// well, now what?
}
})
connected
The session connected to a new ZooKeeper server. This may be emitted more than once per session.
disconnected
The session disconnected from a ZooKeeper server. This may be emitted more than
once per session. It is recommended to stop issuing ZooKeeper requests until the
connected event fires.
expired
The session has expired. Any ephemeral nodes create are gone. You must start()
again before making any other calls or they will throw an Error.
zk.on('expired', function () {
// clean up and reconnect
console.log('crap, my ephemeral nodes are gone')
zk.start()
})
maxReconnectAttempts
This fires when the connection to ZooKeeper could not be restored after options.maxReconnectAttempts tries.
You can listen to watch events globally from the session with these events. The
event includes the path that triggered the watch.
zk.on('changed', function (path) {
console.log('the node at', path, 'changed')
})
A set of policies for retrying requests.
Don't retry.
Retry once, wait milliseconds between requests.
Retry n times, wait milliseconds between requests.
Retry for timespan milliseconds, wait milliseconds between requests.
Retry n times, increasing delay between tries exponentially starting at wait
milliseconds, optionally bounded by maxWait milliseconds.
zk.transaction()
.check('/foo', 4)
.create('/foo/bar', 'bubbles')
.set('/baz', 'buzz', 0)
.del('/cuz', 0)
.commit(
function (errno, results) {
if (!err) {
results.forEach(console.log.bind(this, 'op result'))
}
}
)
Transactions execute all or none of the member operations atomically. Create a
Transaction with zk.transaction() and execute the transaction with commit.
Operations are added to the transaction with the following functions and may be chained.
Create a node
Delete a node
Set the value of a node
Assert that the given version is the latest for path
Execute the transaction.
Create a digest ACL with name, password and permissions
MIT
FAQs
Pure JS Zookeeper Client
The npm package zkjs receives a total of 6 weekly downloads. As such, zkjs popularity was classified as not popular.
We found that zkjs 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.