particle-api-js 9.0.0 → 9.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/particle.min.js +86 -89
- package/dist/particle.min.js.map +1 -1
- package/docs/api.md +154 -99
- package/lib/EventStream.js +0 -1
- package/lib/EventStream.js.map +1 -1
- package/lib/Particle.js +711 -610
- package/lib/Particle.js.map +1 -1
- package/package.json +2 -4
- package/test/EventStream.spec.js +0 -1
- package/test/Particle.spec.js +100 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "particle-api-js",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.1.1",
|
|
4
4
|
"description": "Particle API Client",
|
|
5
5
|
"main": "lib/Particle.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"test:browser": "karma start --single-run",
|
|
13
13
|
"test:watch": "npm run test:node -- --watch",
|
|
14
14
|
"cover": "istanbul cover ./node_modules/.bin/_mocha test/ -- -R spec --compilers js:babel-register",
|
|
15
|
-
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec --compilers js:babel-register test/ && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
|
|
16
15
|
"lint": "eslint . --ext .js --format unix --ignore-path .gitignore --ignore-pattern \"dist/*\"",
|
|
17
16
|
"lint:fix": "npm run lint -- --fix",
|
|
18
17
|
"docs": "documentation build src/Particle.js --shallow -g -f md -o docs/api.md",
|
|
@@ -56,7 +55,6 @@
|
|
|
56
55
|
"browserify": "^13.0.0",
|
|
57
56
|
"chai": "^3.5.0",
|
|
58
57
|
"chai-as-promised": "^5.3.0",
|
|
59
|
-
"coveralls": "^2.11.4",
|
|
60
58
|
"documentation": "^4.0.0-rc.1",
|
|
61
59
|
"eslint": "^5.16.0",
|
|
62
60
|
"eslint-config-particle": "^2.2.1",
|
|
@@ -79,7 +77,7 @@
|
|
|
79
77
|
"dependencies": {
|
|
80
78
|
"babel-runtime": "^6.9.2",
|
|
81
79
|
"form-data": ">2.2.0",
|
|
82
|
-
"stream-http": "
|
|
80
|
+
"stream-http": "^3.2.0",
|
|
83
81
|
"superagent": "^5.1.2",
|
|
84
82
|
"superagent-prefix": "0.0.2"
|
|
85
83
|
},
|
package/test/EventStream.spec.js
CHANGED
package/test/Particle.spec.js
CHANGED
|
@@ -218,6 +218,22 @@ describe('ParticleAPI', () => {
|
|
|
218
218
|
});
|
|
219
219
|
});
|
|
220
220
|
});
|
|
221
|
+
it('allows invalidating tokens', () => {
|
|
222
|
+
return api.confirmMfa(Object.assign({ invalidateTokens: true }, props)).then((results) => {
|
|
223
|
+
results.should.eql({
|
|
224
|
+
uri: '/v1/user/mfa-enable',
|
|
225
|
+
method: 'post',
|
|
226
|
+
auth: props.auth,
|
|
227
|
+
headers: props.headers,
|
|
228
|
+
data: {
|
|
229
|
+
otp: props.otp,
|
|
230
|
+
mfa_token: props.mfaToken,
|
|
231
|
+
invalidate_tokens: true
|
|
232
|
+
},
|
|
233
|
+
context: {}
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
});
|
|
221
237
|
});
|
|
222
238
|
|
|
223
239
|
describe('.disableMfa', () => {
|
|
@@ -306,12 +322,50 @@ describe('ParticleAPI', () => {
|
|
|
306
322
|
});
|
|
307
323
|
});
|
|
308
324
|
|
|
325
|
+
describe('.deleteActiveAccessTokens', () => {
|
|
326
|
+
it('sends request', () => {
|
|
327
|
+
return api.deleteActiveAccessTokens(props).then((results) => {
|
|
328
|
+
results.should.match({
|
|
329
|
+
method: 'delete',
|
|
330
|
+
uri: '/v1/access_tokens',
|
|
331
|
+
auth: props.auth,
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
|
|
309
337
|
describe('.listAccessTokens', () => {
|
|
338
|
+
let options;
|
|
339
|
+
|
|
340
|
+
beforeEach(() => {
|
|
341
|
+
options = {
|
|
342
|
+
username: props.username,
|
|
343
|
+
password: props.password,
|
|
344
|
+
otp: props.otp
|
|
345
|
+
};
|
|
346
|
+
});
|
|
347
|
+
|
|
310
348
|
it('sends credentials', () => {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
349
|
+
delete options.otp;
|
|
350
|
+
return api.listAccessTokens(options)
|
|
351
|
+
.then(({ auth, query }) => {
|
|
352
|
+
expect(auth).to.be.an('object');
|
|
353
|
+
expect(auth).to.have.property('username', options.username);
|
|
354
|
+
expect(auth).to.have.property('password', options.password);
|
|
355
|
+
expect(query).to.equal(undefined);
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it('includes otp when provided', () => {
|
|
360
|
+
return api.listAccessTokens(options)
|
|
361
|
+
.then(({ auth, query }) => {
|
|
362
|
+
expect(auth).to.be.an('object');
|
|
363
|
+
expect(auth).to.have.property('username', options.username);
|
|
364
|
+
expect(auth).to.have.property('password', options.password);
|
|
365
|
+
expect(query).to.be.an('object');
|
|
366
|
+
expect(query).to.have.property('otp', props.otp);
|
|
367
|
+
expect(props.otp).to.be.a('string').with.lengthOf(6);
|
|
368
|
+
});
|
|
315
369
|
});
|
|
316
370
|
});
|
|
317
371
|
|
|
@@ -1356,6 +1410,23 @@ describe('ParticleAPI', () => {
|
|
|
1356
1410
|
});
|
|
1357
1411
|
});
|
|
1358
1412
|
});
|
|
1413
|
+
it('allows invalidating tokens', () => {
|
|
1414
|
+
return api.changeUsername({ auth: 'X', currentPassword: 'blabla', username: 'john@skul.ly', invalidateTokens: true })
|
|
1415
|
+
.then((results) => {
|
|
1416
|
+
results.should.eql({
|
|
1417
|
+
uri: '/v1/user',
|
|
1418
|
+
method: 'put',
|
|
1419
|
+
auth: 'X',
|
|
1420
|
+
headers: undefined,
|
|
1421
|
+
data: {
|
|
1422
|
+
current_password: 'blabla',
|
|
1423
|
+
username: 'john@skul.ly',
|
|
1424
|
+
invalidate_tokens: true
|
|
1425
|
+
},
|
|
1426
|
+
context: {}
|
|
1427
|
+
});
|
|
1428
|
+
});
|
|
1429
|
+
});
|
|
1359
1430
|
});
|
|
1360
1431
|
|
|
1361
1432
|
describe('.changeUserPassword', () => {
|
|
@@ -2341,6 +2412,31 @@ describe('ParticleAPI', () => {
|
|
|
2341
2412
|
});
|
|
2342
2413
|
});
|
|
2343
2414
|
|
|
2415
|
+
describe('.getProductDeviceConfiguration', () => {
|
|
2416
|
+
it('generates request', () => {
|
|
2417
|
+
return api.getProductDeviceConfiguration(propsWithProduct).then((results) => {
|
|
2418
|
+
results.should.match({
|
|
2419
|
+
method: 'get',
|
|
2420
|
+
uri: `/v1/products/${product}/config/${props.deviceId}`,
|
|
2421
|
+
auth: props.auth
|
|
2422
|
+
});
|
|
2423
|
+
});
|
|
2424
|
+
});
|
|
2425
|
+
});
|
|
2426
|
+
|
|
2427
|
+
describe('.getProductDeviceConfigurationSchema', () => {
|
|
2428
|
+
it('generates request', () => {
|
|
2429
|
+
return api.getProductDeviceConfigurationSchema(propsWithProduct).then((results) => {
|
|
2430
|
+
results.should.match({
|
|
2431
|
+
method: 'get',
|
|
2432
|
+
uri: `/v1/products/${product}/config/${props.deviceId}`,
|
|
2433
|
+
auth: props.auth,
|
|
2434
|
+
headers: { 'accept': 'application/schema+json' }
|
|
2435
|
+
});
|
|
2436
|
+
});
|
|
2437
|
+
});
|
|
2438
|
+
});
|
|
2439
|
+
|
|
2344
2440
|
describe('.setProductConfiguration', () => {
|
|
2345
2441
|
it('generates request', () => {
|
|
2346
2442
|
const p = Object.assign({ config: {
|