
Research
/Security News
Shai Hulud Strikes Again (v2)
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.
urban-airship-connect
Advanced tools
A node library for Airship's Real Time Data Streaming (formerly Connect)
var connect = require('urban-airship-connect')
var connectStream = connect('appKey', 'authToken')
connectStream.on('data', function (data) {
// will be called with each event
})
// write to the stream to set filters/offset/start
connectStream.write({start: 'LATEST'})
connect(appKey, authToken[, options]) -> duplexStream
appKey is your Airship app keyauthToken is your RTDS auth tokenoptions is an optional object accepting parameters:
uri to specify the URI to a running RTDS instanceparser to specify a custom JSON parser of signature:
parse(String) -> Object; defaults to JSON.parseThe returned duplex stream reads and writes plain JavaScript objects. Writes are posted to RTDS (Real Time Data Streaming), and the responding events are emitted as plain JavaScript objects over time.
If an error is encountered during a request, a bad status code is encountered,
or JSON parsing of an event fails, an 'error' event will be emitted with the
error attached. For JSON parse errors, the blob that caused the error will be
available as the blob property of the error.
It is possible for a Custom Event value to be a number that cannot be parsed by JavaScript see docs. If you suspect you might encounter this issue, you may want to provide your own JSON parser, see API.
This module will handle connecting and maintaining a connection to Airship's Real Time Data Streaming service. If its connection is ever severed, it will do its best to resume at the last seen offset.
The resume_offset is not stored externally, so if the process using this
module is killed, crashes, or otherwise exits it will be lost. In general it is
advisable to track this offset yourself.
var fs = require('fs')
var connect = require('urban-airship-connect')
var lookupStream = require('dotpath-stream')
var writeFile = require('file-replace-stream')
var connectStream = connect('appKey', 'authToken')
var filters = {}
// set up our pipeline for saving offsets
connectStream
// pull out just the `offset` property
.pipe(lookupStream('offset'))
// write it to `last_offset.txt`
.pipe(writeFile('last_offset.txt'))
try {
// try to read our offset file
filters.resume_offset = fs.readFileSync('last_offset.txt', {encoding: 'utf8'})
} catch (err) {
// fall back to starting at latest offset
filters.start = 'LATEST'
}
// write the filters to RTDS to start streaming events
connectStream.write(filters)
writeFile could be swapped out for any writable stream for persistence.data
event of connectStream and persist the offset property from the passed
event however you please.A simple command-line utility ua-connect is bundled along with this module. It
should be mostly used for testing your credentials or other aspects of your
RTDS setup, not for anything "mission-critical".
ua-connect <app-key> <token> [options]
Where options are:
--uri <uri> Use a custom uri for RTDS--offset <offset> Start at <offset>--earliest Start at earliest offset--key <app-key> Explicitly set app key--token <token> Explicitly set tokenApache-2.0
FAQs
node client for Airship's Real Time Data Streaming
The npm package urban-airship-connect receives a total of 49 weekly downloads. As such, urban-airship-connect popularity was classified as not popular.
We found that urban-airship-connect 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
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.