
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Helpful utilities for developing oak applications

npm install --save oak-tools
Head on over to the documentation page!
oak-tools consists of a few helpful utility methods. Everything exposed from the module is a Class and needs to be constructed using new, except the logger
logger()
The logger is based off pino and has nearly the same same option parameters. The following example are the default options.
const { logger } = require('oak-tools')
let log = logger({
// these are the default properties
level: 'info',
stream: process.stdout,
pretty: false
})
log.info('sup')
log.error({
err: new Error('crap...')
})
log.debug({
msg: 'debug message here',
now: Date.now()
})
server(type)
The server is extended from a good 'ol EventEmitter2. Head here for full documentation on the server class
const msgpack = require('msgpack5')()
const Server = require('oak-tools').server('websocket')
// all these options are, well... optional
let server = new Server({
// these are the default properties
port: 9500,
host: 'localhost',
serializer: { encode, decode } = msgpack
})
server
.on('error', function (err) {
console.error('* client error', err)
})
.on('connection', function (ID) {
console.log('* client connection: ', ID)
})
.on('reconnect', function (ID) {
console.log('* client reconnect: ', ID)
})
.on('close', function (ID) {
console.log('* client closed', ID)
})
.on('who.is.the.man.now', function () {
server.pub('heres.who', {
answer: 'you are. http://www.yourethemannowdog.com/'
})
})
client(type)
The client API is similar to server, but it has both a sub and a pub method.
const { join } = require('path')
let Client = require(join(__dirname, '..')).client('websocket')
let client = new Client({
id: 'sean connery' // defaults to random UUID
})
client.on('ready', function () {
console.log('* client is connected')
client
.on('heres.who', function ({ answer }) {
console.log(answer)
})
.pub('who.is.the.man.now')
})
The goal of the server/client is to wrap up all the higher level messaging operations to be more protocol agnostic (as well as non-repetitive). This means we have a couple more steps than a normal TCP or WebSocket flow:
Client -> Server
Client publishes on a namespace
client > pub('foo.bar', { my: 'message' })
The namespace and message get split into an flat array, where the last item is the message
client > outbound message [ 'foo', 'bar', { my: 'message' } ]
Payload gets encoded by the client
client > encode(array) // <Buffer a5 68 65 6c 6c 6f>
Client sends encoded message to the server
client > send(payload)
Server receives payload Buffer
server > on('message', decode)
Server receives and unpacks the payload
server > decode(payload) // our array
Server reconstructs the array, and emits the message
server > emit('foo.bar', { my: 'message' })
Server -> Client(s)
Client sends a subscription message to the server, through its binding
client > on('foo.*', handler)
Server receives a subscription event from the client
server > on('_sub') // remember client wants 'foo.*' messages
Time passes...
Server sends an event to all clients that subscribed
server > pub('foo.baz', { my: 'message' }) // matches anyone who sent _sub to foo.*
Encode and write the same way the client does to each socket
server > each connections send(payload)
Client receives payload, unpacks, and emits it
client > on('foo.*', fn(data)) // this.event === foo.baz
Serializer
On both server and client, encoder and decoder to pass messages. The serializer consists of the encoding and decoding methods to use against payloads.
By default, we use msgpack5, but doing something as simple as this will work:
new clientOrServer({
serializer: {
encode: JSON.stringify,
decode: JSON.parse
}
})
| Package | Version | Dev |
|---|---|---|
| eventemitter2 | ~4.1.0 | ✖ |
| mdns-js | ~0.5.3 | ✖ |
| minimatch | ~3.0.3 | ✖ |
| msgpack5 | ~3.4.1 | ✖ |
| pino | ~4.4.0 | ✖ |
| safe-buffer | ~5.1.0 | ✖ |
| swagger-client | ~3.0.2 | ✖ |
| uuid | ~3.0.1 | ✖ |
| ws | ~3.0.0 | ✖ |
| ws-heartbeats | ~1.0.0 | ✖ |
| coveralls | ~2.13.0 | ✔ |
| docdash | ~0.4.0 | ✔ |
| istanbul | ~0.4.5 | ✔ |
| jsdoc | ~3.5.0 | ✔ |
| node-readme | ~0.1.9 | ✔ |
| standard | ~10.0.0 | ✔ |
| tap-difflet | ~0.7.0 | ✔ |
| tape | ~4.7.0 | ✔ |
Contributions welcome; Please submit all pull requests against the master branch. If your pull request contains patches or features, you should include relevant unit tests. Thanks!
FAQs
Helpful utilities for developing oak applications
The npm package oak-tools receives a total of 4 weekly downloads. As such, oak-tools popularity was classified as not popular.
We found that oak-tools 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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.