New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

particle-api-js

Package Overview
Dependencies
Maintainers
4
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

particle-api-js - npm Package Compare versions

Comparing version 6.0.8 to 6.1.0

.env

4

CHANGELOG.md
# changelog
## 6.1.0 - 19 Nov 2016
* Add library publish
## 6.0.8 - 17 Nov 2016

@@ -4,0 +8,0 @@

68

docs/api.md
# Particle
[src/Particle.js:17-547](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L17-L547 "Source code on GitHub")
[src/Particle.js:17-551](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L17-L551 "Source code on GitHub")

@@ -15,3 +15,3 @@ Particle Cloud API wrapper.

[src/Particle.js:283-287](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L283-L287 "Source code on GitHub")
[src/Particle.js:283-287](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L283-L287 "Source code on GitHub")

@@ -32,3 +32,3 @@ Call a device function

[src/Particle.js:117-122](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L117-L122 "Source code on GitHub")
[src/Particle.js:117-122](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L117-L122 "Source code on GitHub")

@@ -48,3 +48,3 @@ Claim a device to the account. The device must be online and unclaimed.

[src/Particle.js:229-238](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L229-L238 "Source code on GitHub")
[src/Particle.js:229-238](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L229-L238 "Source code on GitHub")

@@ -65,3 +65,3 @@ Compile firmware using the Particle Cloud

[src/Particle.js:25-28](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L25-L28 "Source code on GitHub")
[src/Particle.js:25-28](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L25-L28 "Source code on GitHub")

@@ -78,3 +78,3 @@ Contructor for the Cloud API wrapper.

[src/Particle.js:482-489](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L482-L489 "Source code on GitHub")
[src/Particle.js:482-489](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L482-L489 "Source code on GitHub")

@@ -93,3 +93,3 @@ Contribute a new library version int the compressed archive

[src/Particle.js:54-58](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L54-L58 "Source code on GitHub")
[src/Particle.js:54-58](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L54-L58 "Source code on GitHub")

@@ -108,3 +108,3 @@ Create a user account for the Particle Cloud

[src/Particle.js:358-366](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L358-L366 "Source code on GitHub")
[src/Particle.js:358-366](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L358-L366 "Source code on GitHub")

@@ -134,3 +134,3 @@ Create a webhook

[src/Particle.js:498-500](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L498-L500 "Source code on GitHub")
[src/Particle.js:502-504](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L502-L504 "Source code on GitHub")

@@ -150,3 +150,3 @@ Delete one version of a library or an entire published library

[src/Particle.js:374-376](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L374-L376 "Source code on GitHub")
[src/Particle.js:374-376](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L374-L376 "Source code on GitHub")

@@ -165,3 +165,3 @@ Delete a webhook

[src/Particle.js:507-518](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L507-L518 "Source code on GitHub")
[src/Particle.js:511-522](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L511-L522 "Source code on GitHub")

@@ -179,3 +179,3 @@ Download an external file that may not be on the API

[src/Particle.js:246-255](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L246-L255 "Source code on GitHub")
[src/Particle.js:246-255](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L246-L255 "Source code on GitHub")

@@ -194,3 +194,3 @@ Download a firmware binary

[src/Particle.js:198-207](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L198-L207 "Source code on GitHub")
[src/Particle.js:198-207](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L198-L207 "Source code on GitHub")

@@ -211,3 +211,3 @@ Compile and flash application firmware to a device

[src/Particle.js:215-219](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L215-L219 "Source code on GitHub")
[src/Particle.js:215-219](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L215-L219 "Source code on GitHub")

@@ -226,3 +226,3 @@ Flash the Tinker application to a device

[src/Particle.js:151-153](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L151-L153 "Source code on GitHub")
[src/Particle.js:151-153](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L151-L153 "Source code on GitHub")

@@ -241,3 +241,3 @@ Generate a claim code to use in the device claiming process.

[src/Particle.js:107-109](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L107-L109 "Source code on GitHub")
[src/Particle.js:107-109](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L107-L109 "Source code on GitHub")

@@ -256,3 +256,3 @@ Get detailed informationa about a device

[src/Particle.js:299-323](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L299-L323 "Source code on GitHub")
[src/Particle.js:299-323](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L299-L323 "Source code on GitHub")

@@ -275,3 +275,3 @@ Get a stream of events

[src/Particle.js:457-459](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L457-L459 "Source code on GitHub")
[src/Particle.js:457-459](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L457-L459 "Source code on GitHub")

@@ -291,3 +291,3 @@ Get firmware library details

[src/Particle.js:469-474](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L469-L474 "Source code on GitHub")
[src/Particle.js:469-474](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L469-L474 "Source code on GitHub")

@@ -308,3 +308,3 @@ Firmware library details for each version

[src/Particle.js:392-394](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L392-L394 "Source code on GitHub")
[src/Particle.js:392-394](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L392-L394 "Source code on GitHub")

@@ -322,3 +322,3 @@ Get details about the current user

[src/Particle.js:173-175](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L173-L175 "Source code on GitHub")
[src/Particle.js:173-175](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L173-L175 "Source code on GitHub")

@@ -338,3 +338,3 @@ Get the value of a device variable

[src/Particle.js:88-90](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L88-L90 "Source code on GitHub")
[src/Particle.js:88-90](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L88-L90 "Source code on GitHub")

@@ -353,3 +353,3 @@ List all valid access tokens for a Particle Cloud account

[src/Particle.js:420-426](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L420-L426 "Source code on GitHub")
[src/Particle.js:420-426](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L420-L426 "Source code on GitHub")

@@ -368,3 +368,3 @@ List valid build targets to be used for compiling

[src/Particle.js:97-99](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L97-L99 "Source code on GitHub")
[src/Particle.js:97-99](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L97-L99 "Source code on GitHub")

@@ -382,3 +382,3 @@ List devices claimed to the account

[src/Particle.js:439-448](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L439-L448 "Source code on GitHub")
[src/Particle.js:439-448](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L439-L448 "Source code on GitHub")

@@ -402,3 +402,3 @@ List firmware libraries

[src/Particle.js:383-385](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L383-L385 "Source code on GitHub")
[src/Particle.js:383-385](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L383-L385 "Source code on GitHub")

@@ -416,3 +416,3 @@ List all webhooks owned by the account

[src/Particle.js:37-46](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L37-L46 "Source code on GitHub")
[src/Particle.js:37-46](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L37-L46 "Source code on GitHub")

@@ -432,3 +432,3 @@ Login to Particle Cloud using an existing Particle acccount.

[src/Particle.js:333-339](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L333-L339 "Source code on GitHub")
[src/Particle.js:333-339](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L333-L339 "Source code on GitHub")

@@ -449,3 +449,3 @@ Publish a event to the Particle Cloud

[src/Particle.js:76-80](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L76-L80 "Source code on GitHub")
[src/Particle.js:76-80](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L76-L80 "Source code on GitHub")

@@ -465,3 +465,3 @@ Revoke an access token

[src/Particle.js:130-132](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L130-L132 "Source code on GitHub")
[src/Particle.js:130-132](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L130-L132 "Source code on GitHub")

@@ -480,3 +480,3 @@ Unclaim / Remove a device from your account

[src/Particle.js:141-143](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L141-L143 "Source code on GitHub")
[src/Particle.js:141-143](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L141-L143 "Source code on GitHub")

@@ -496,3 +496,3 @@ Rename a device

[src/Particle.js:65-67](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L65-L67 "Source code on GitHub")
[src/Particle.js:65-67](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L65-L67 "Source code on GitHub")

@@ -510,3 +510,3 @@ Send reset password email for a Particle Cloud user account

[src/Particle.js:265-273](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L265-L273 "Source code on GitHub")
[src/Particle.js:265-273](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L265-L273 "Source code on GitHub")

@@ -527,3 +527,3 @@ Send a new device public key to the Particle Cloud

[src/Particle.js:184-188](https://github.com/spark/particle-api-js/blob/214e1ed88049c171d854b026dd4739549ca89323/src/Particle.js#L184-L188 "Source code on GitHub")
[src/Particle.js:184-188](https://github.com/spark/particle-api-js/blob/17879d8a79c1caf2b9ae1845b65d6d6a95ed576c/src/Particle.js#L184-L188 "Source code on GitHub")

@@ -530,0 +530,0 @@ Instruct the device to turn on/off the LED in a rainbow pattern

@@ -104,3 +104,3 @@ 'use strict';

/**
* Publish a new library version
* Contribute a new library version
* @param {Buffer} archive The compressed archive with the library source

@@ -124,2 +124,21 @@ * @return {Promise}

/**
* Make the the most recent private library version public
* @param {string} name The name of the library to publish
* @return {Promise} To publish the library
*/
}, {
key: 'publishLibrary',
value: function publishLibrary(name) {
var _this5 = this;
return this.api.publishLibrary({ name: name, auth: this.auth }).then(function (payload) {
var library = payload.body.data || {};
return new _Library2.default(_this5, library);
}, function (error) {
_this5._throwError(error);
});
}
/**
* Delete an entire published library

@@ -134,3 +153,3 @@ * @param {String} $0.name Name of the library to delete

value: function deleteLibrary(_ref2) {
var _this5 = this;
var _this6 = this;

@@ -144,3 +163,3 @@ var name = _ref2.name;

}, function (error) {
_this5._throwError(error);
_this6._throwError(error);
});

@@ -147,0 +166,0 @@ }

@@ -772,3 +772,11 @@ 'use strict';

}
}, {
key: 'publishLibrary',
value: function publishLibrary(_ref36) {
var auth = _ref36.auth;
var name = _ref36.name;
return this.request({ uri: '/v1/libraries/' + name, auth: auth, method: 'patch', data: { visibility: 'public' } });
}
/**

@@ -784,6 +792,6 @@ * Delete one version of a library or an entire published library

key: 'deleteLibrary',
value: function deleteLibrary(_ref36) {
var auth = _ref36.auth;
var name = _ref36.name;
var force = _ref36.force;
value: function deleteLibrary(_ref37) {
var auth = _ref37.auth;
var name = _ref37.name;
var force = _ref37.force;

@@ -801,4 +809,4 @@ return this.delete('/v1/libraries/' + name, { force: force }, auth);

key: 'downloadFile',
value: function downloadFile(_ref37) {
var url = _ref37.url;
value: function downloadFile(_ref38) {
var url = _ref38.url;

@@ -805,0 +813,0 @@ var req = _superagent2.default.get(url);

{
"name": "particle-api-js",
"version": "6.0.8",
"version": "6.1.0",
"description": "Particle API Client",

@@ -67,2 +67,3 @@ "main": "lib/Particle.js",

"sinon": "^1.17.4",
"sinon-as-promised": "^4.0.2",
"sinon-chai": "^2.8.0",

@@ -69,0 +70,0 @@ "watchify": "^3.7.0"

@@ -28,12 +28,14 @@ /*

describe('Agent', () => {
it('can fetch a webpage', () => {
const sut = new Agent();
const args = {a: '1', b: '2'};
const result = sut.get('http://httpbin.org/get', undefined, args);
return result.then((r)=> {
expect(r.statusCode).to.equal(200);
expect(r).has.property('body');
expect(r.body.args).to.deep.equal(args);
if (!process.env.SKIP_AGENT_TEST) {
it('can fetch a webpage', () => {
const sut = new Agent();
const args = {a: '1', b: '2'};
const result = sut.get('http://httpbin.org/get', undefined, args);
return result.then((r)=> {
expect(r.statusCode).to.equal(200);
expect(r).has.property('body');
expect(r.body.args).to.deep.equal(args);
});
});
});
}
});

@@ -1,11 +0,13 @@

import {expect} from './test-setup';
import {expect, sinon} from './test-setup';
import Client from '../src/Client';
import * as fixtures from './fixtures';
import Library from '../src/Library';
let api = {};
let token = "tok";
let api;
const token = 'tok';
let client;
describe('Client', () => {
beforeEach(() => {
api = {};
client = new Client({ api: api, auth: token });

@@ -69,2 +71,60 @@ });

});
describe('publishLibrary', () => {
it('delegates to api and returns the library metadata on success', () => {
const name = 'fred';
const metadata = {name};
const library = new Library(client, metadata);
api.publishLibrary = sinon.stub().resolves({body: {data: metadata}});
return client.publishLibrary(name).
then(actual => {
expect(actual).to.eql(library);
expect(api.publishLibrary).to.have.been.calledWith({name, auth:token});
});
});
it('delegates to api and calls _throwError to handle the error', () => {
const error = {message:'I don\'t like vegetables'};
api.publishLibrary = sinon.stub().rejects(error);
const name = 'notused';
return client.publishLibrary(name)
.then(() => {
throw new Error('expected an exception');
})
.catch(actual => {
expect(actual).to.eql(error);
expect(api.publishLibrary).to.have.been.calledWith({name, auth:token});
});
});
});
describe('contributeLibrary', () => {
it('delegates to api and returns the library metadata on success', () => {
const archive = {};
const metadata = {name:''};
const library = new Library(client, metadata);
api.contributeLibrary = sinon.stub().resolves({body: { data: metadata}});
return client.contributeLibrary(archive).
then(actual => {
expect(actual).to.eql(library);
expect(api.contributeLibrary).to.have.been.calledWith({archive, auth:token});
});
});
it('delegates to api and calls _throwError to handle the error', () => {
const archive = {};
const error = {message:'I don\'t like vegetables'};
api.contributeLibrary = sinon.stub().rejects(error);
return client.contributeLibrary(archive)
.then(() => {
throw new Error('expected an exception');
})
.catch(actual => {
expect(actual).to.eql(error);
expect(api.contributeLibrary).to.have.been.calledWith({archive, auth:token});
});
});
});
});
const fs = require('fs'); // import syntax doesn't work inside karma
const fixtures = {
'libraries.json': fs.readFileSync(__dirname + '/libraries.json'),
'library.json': fs.readFileSync(__dirname + '/library.json'),
'libraryVersions.json': fs.readFileSync(__dirname + '/libraryVersions.json'),
};
const fixtureNames = [
'libraries.json',
'library.json',
'libraryVersions.json',
'test-library-publish-0.0.1.tar.gz',
'test-library-publish-0.0.2.tar.gz'
];
function readFixtures(fixtureNames) {
const fixtures = {};
for (let idx in fixtureNames) {
const name = fixtureNames[idx];
fixtures[name] = fs.readFileSync(`${__dirname}/${name}`);
}
return fixtures;
}
const fixtures = readFixtures(fixtureNames);
function read(filename) {

@@ -10,0 +23,0 @@ if (!fixtures[filename]) {

@@ -546,2 +546,20 @@ import should from 'should'; // monkeypatch the world~!1

});
describe('.publishLibrary', () => {
it('generates request', () => {
const name = 'noname';
return api.publishLibrary({
name,
auth: 'X'
}).then((results) => {
results.should.match({
method: 'patch',
uri: '/v1/libraries/noname',
auth: 'X',
data: {
visibility: 'public'
}
});
});
});
});
describe('.deleteLibrary', () => {

@@ -548,0 +566,0 @@ it('generates request', () => {

@@ -8,2 +8,3 @@ // Set up the Mocha test framework with the Chai assertion library and

import chaiAsPromised from 'chai-as-promised';
import sinonAsPromised from 'sinon-as-promised';

@@ -17,3 +18,4 @@ chai.use(sinonChai);

sinon,
expect
expect,
sinonAsPromised
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc