particle-api-js 10.6.0 → 11.0.0
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 +4 -0
- package/dist/particle.min.js +1 -1
- package/dist/particle.min.js.map +1 -1
- package/docs/api.md +255 -291
- package/package.json +1 -1
- package/src/Agent.js +10 -33
- package/src/EventStream.js +4 -1
- package/src/Particle.js +123 -169
- package/test/Agent.spec.js +0 -22
- package/test/EventStream.spec.js +4 -1
- package/test/Particle.spec.js +1 -57
package/test/Agent.spec.js
CHANGED
|
@@ -108,28 +108,6 @@ describe('Agent', () => {
|
|
|
108
108
|
const headers = agent._getAuthorizationHeader(auth);
|
|
109
109
|
expect(headers).to.eql({ Authorization: bearer });
|
|
110
110
|
});
|
|
111
|
-
|
|
112
|
-
if (typeof window !== 'undefined') {
|
|
113
|
-
it('supports auth with user/pass in browsers', () => {
|
|
114
|
-
const auth = {
|
|
115
|
-
username: 'test@particle.io',
|
|
116
|
-
password: 'super_secret'
|
|
117
|
-
};
|
|
118
|
-
const basic = 'Basic dGVzdEBwYXJ0aWNsZS5pbzpzdXBlcl9zZWNyZXQ=';
|
|
119
|
-
const headers = agent._getAuthorizationHeader(auth);
|
|
120
|
-
expect(headers).to.eql({ Authorization: basic });
|
|
121
|
-
});
|
|
122
|
-
} else {
|
|
123
|
-
it('supports auth with user/pass in node', () => {
|
|
124
|
-
const auth = {
|
|
125
|
-
username: 'test@particle.io',
|
|
126
|
-
password: 'super_secret'
|
|
127
|
-
};
|
|
128
|
-
const basic = 'Basic dGVzdEBwYXJ0aWNsZS5pbzpzdXBlcl9zZWNyZXQ=';
|
|
129
|
-
const headers = agent._getAuthorizationHeader(auth);
|
|
130
|
-
expect(headers).to.eql({ Authorization: basic });
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
111
|
});
|
|
134
112
|
|
|
135
113
|
describe('request', () => {
|
package/test/EventStream.spec.js
CHANGED
|
@@ -49,7 +49,10 @@ describe('EventStream', () => {
|
|
|
49
49
|
expect(http.request).to.have.been.calledWith({
|
|
50
50
|
hostname: 'hostname',
|
|
51
51
|
protocol: 'http:',
|
|
52
|
-
path: '/path
|
|
52
|
+
path: '/path',
|
|
53
|
+
headers: {
|
|
54
|
+
'Authorization': 'Bearer token'
|
|
55
|
+
},
|
|
53
56
|
method: 'get',
|
|
54
57
|
port: 8080,
|
|
55
58
|
mode: 'prefer-streaming'
|
package/test/Particle.spec.js
CHANGED
|
@@ -389,21 +389,6 @@ describe('ParticleAPI', () => {
|
|
|
389
389
|
});
|
|
390
390
|
});
|
|
391
391
|
|
|
392
|
-
describe('.deleteAccessToken', () => {
|
|
393
|
-
it('sends request', () => {
|
|
394
|
-
return api.deleteAccessToken(props).then((results) => {
|
|
395
|
-
results.should.match({
|
|
396
|
-
method: 'delete',
|
|
397
|
-
uri: `/v1/access_tokens/${props.token}`,
|
|
398
|
-
auth: {
|
|
399
|
-
username: props.username,
|
|
400
|
-
password: props.password
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
});
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
|
|
407
392
|
describe('.deleteCurrentAccessToken', () => {
|
|
408
393
|
it('sends request', () => {
|
|
409
394
|
return api.deleteCurrentAccessToken(props).then((results) => {
|
|
@@ -428,41 +413,6 @@ describe('ParticleAPI', () => {
|
|
|
428
413
|
});
|
|
429
414
|
});
|
|
430
415
|
|
|
431
|
-
describe('.listAccessTokens', () => {
|
|
432
|
-
let options;
|
|
433
|
-
|
|
434
|
-
beforeEach(() => {
|
|
435
|
-
options = {
|
|
436
|
-
username: props.username,
|
|
437
|
-
password: props.password,
|
|
438
|
-
otp: props.otp
|
|
439
|
-
};
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
it('sends credentials', () => {
|
|
443
|
-
delete options.otp;
|
|
444
|
-
return api.listAccessTokens(options)
|
|
445
|
-
.then(({ auth, query }) => {
|
|
446
|
-
expect(auth).to.be.an('object');
|
|
447
|
-
expect(auth).to.have.property('username', options.username);
|
|
448
|
-
expect(auth).to.have.property('password', options.password);
|
|
449
|
-
expect(query).to.equal(undefined);
|
|
450
|
-
});
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
it('includes otp when provided', () => {
|
|
454
|
-
return api.listAccessTokens(options)
|
|
455
|
-
.then(({ auth, query }) => {
|
|
456
|
-
expect(auth).to.be.an('object');
|
|
457
|
-
expect(auth).to.have.property('username', options.username);
|
|
458
|
-
expect(auth).to.have.property('password', options.password);
|
|
459
|
-
expect(query).to.be.an('object');
|
|
460
|
-
expect(query).to.have.property('otp', props.otp);
|
|
461
|
-
expect(props.otp).to.be.a('string').with.lengthOf(6);
|
|
462
|
-
});
|
|
463
|
-
});
|
|
464
|
-
});
|
|
465
|
-
|
|
466
416
|
describe('.listDevices', () => {
|
|
467
417
|
describe('user scope', () => {
|
|
468
418
|
it('generates request', () => {
|
|
@@ -2987,12 +2937,6 @@ describe('ParticleAPI', () => {
|
|
|
2987
2937
|
});
|
|
2988
2938
|
});
|
|
2989
2939
|
|
|
2990
|
-
describe('backwards-compatibility function aliases', () => {
|
|
2991
|
-
it('maps removeAccessToken to deleteAccessToken', () => {
|
|
2992
|
-
api.removeAccessToken.should.equal(api.deleteAccessToken);
|
|
2993
|
-
});
|
|
2994
|
-
});
|
|
2995
|
-
|
|
2996
2940
|
describe('.deviceUri', () => {
|
|
2997
2941
|
describe('user scope', () => {
|
|
2998
2942
|
it('gets the user device uri', () => {
|
|
@@ -3211,7 +3155,7 @@ describe('ParticleAPI', () => {
|
|
|
3211
3155
|
error = e;
|
|
3212
3156
|
}
|
|
3213
3157
|
expect(error).to.be.an.instanceOf(Error);
|
|
3214
|
-
expect(error.message).to.eql('Must pass a non-empty string
|
|
3158
|
+
expect(error.message).to.eql('Must pass a non-empty string representing an auth token!');
|
|
3215
3159
|
});
|
|
3216
3160
|
});
|
|
3217
3161
|
|