Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@dispatch/dispatch-node-sdk
Advanced tools
High- and low-level libraries for interacting with the Dispatch API
Readme
High- and low-level libraries for interacting with the Dispatch API.
$ npm install --save dispatch-node-sdk
The client SDK is meant for use on the browser. It assumes that there is only one active bearer token at a time - for server-level use, please use the raw Client
.
Create a new instance of the client with your client_id
and client_secret
.
import Dispatch from 'dispatch-node-sdk';
const dispatchClient = new Dispatch(clientID, clientSecret, 'https://api.dispatch.me');
You can manually set the API bearer token if it came from an external source:
client.setBearerToken(bearerToken, refreshToken);
client.loginEmailPassword(email, password).then(token => {
return client.identifyUser()
}).then(user => {
console.log('Current user is', user);
}).catch(err => console.error('Failed to log in:', err));
client.requestVerificationCode('+15555555555').then(() => {
alert('Verification code will be sent to your phone!');
}).catch(err => alert('Error getting verification code'));
// Later...
client.loginPhoneNumber('+15555555555', verificationCode).then(token => {
alert('Got bearer token: ' + token);
}).catch(err => alert('Error logging in!'));
By default, the SDK wraps each entity in a Model
class, (very similar to a Backbone model), which exposes methods like refresh
, set
, get
, and save
.
For example, get a list of unscheduled jobs:
client.getCollection('/v1/jobs', {
status_eq: 'unscheduled'
}).then(jobs => {
jobs.forEach(job => console.log('Got job ID ' + job.get('id')));
}).catch(err => alert('Error loading jobs!'));
Once you have a model, you can modify it and save it:
model.set('status', 'scheduled');
model.save().then(() => {
alert('Saved!');
}).catch(err => alert('Error saving job!'));
Sometimes you may want to just get a single model instead of an entire collection. For example, to retrieve job #1:
client.getModel('/v1/jobs', 1)
.then(job => alert('Job 1 has status: ' + job.get('status')))
.catch(err => alert('Error loading job #1'));
Use the low-level raw client on the server-side for shared-key authentication:
import { RawClient, AUTH_MODE_HMAC } from 'dispatch-node-sdk';
const client = new RawClient({
authMode: AUTH_MODE_HMAC,
hmacCredentials: {
userID: 10,
userType: 'user',
secret: '<secret key>',
},
host: 'https://api-sandbox.dispatch.me',
});
client.get('/v1/jobs')
.then(jobs => console.log('Got %d jobs', jobs.length))
.catch(err => console.error(err));
FAQs
High- and low-level libraries for interacting with the Dispatch API
The npm package @dispatch/dispatch-node-sdk receives a total of 0 weekly downloads. As such, @dispatch/dispatch-node-sdk popularity was classified as not popular.
We found that @dispatch/dispatch-node-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.