From 0d0d0100899790eab9980701fcbe26207040464b Mon Sep 17 00:00:00 2001 From: Chris Tobolski Date: Wed, 12 Feb 2020 20:03:12 -0500 Subject: [PATCH 01/13] Minor readme fix for yarn installation and getting configuration without using deprecated method --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0c2ea46..915e074 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ $ npm install node-hue-api Node.js using yarn: ``` -$ yarn install node-hue-api +$ yarn add node-hue-api ``` ## v3 API @@ -268,7 +268,7 @@ async function discoverAndCreateUser() { const authenticatedApi = await hueApi.createLocal(ipAddress).connect(createdUser.username); // Do something with the authenticated user/api - const bridgeConfig = await authenticatedApi.configuration.get(); + const bridgeConfig = await authenticatedApi.configuration.getConfiguration(); console.log(`Connected to Hue Bridge: ${bridgeConfig.name} :: ${bridgeConfig.ipaddress}`); } catch(err) { From f0855991ffc2c1dfed4117a409fd0f6d7c3ab553 Mon Sep 17 00:00:00 2001 From: Peter Murray <681306+peter-murray@users.noreply.github.com> Date: Mon, 9 Mar 2020 11:52:08 +0000 Subject: [PATCH 02/13] Issue #168, N-UPnP discovery endpoint returning invalid bridges for a user which breaks discovery results --- Changelog.md | 4 ++++ docs/discovery.md | 18 +++++++++++++++++- index.js | 2 ++ lib/api/discovery/index.js | 13 ++++++++++++- lib/api/discovery/index.test.js | 6 ++---- lib/v3.js | 29 ++++++++++++++++++++++++++++- package.json | 2 +- 7 files changed, 66 insertions(+), 8 deletions(-) diff --git a/Changelog.md b/Changelog.md index 55b6546..1aba351 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Change Log +#5.0.0-alpha.1 +- Providing a fix for the discovery portal (N-UPnP search) issues where a user has multiple bridges, where some of +them are invalid. This changes the return value for discovery requiring a major version bump. Issue #168. + #4.0.5 - Various TypeScript definition fixes including Issue #166. diff --git a/docs/discovery.md b/docs/discovery.md index 7a1123d..d9e8e46 100644 --- a/docs/discovery.md +++ b/docs/discovery.md @@ -33,7 +33,7 @@ async function getBridge() { getBridge(); ``` -The results will be an array of discovered bridges with the following structure: +The results will be an array of valid discovered bridges with the following structure: ```json [ @@ -46,6 +46,22 @@ The results will be an array of discovered bridges with the following structure: ] ``` +If a bridge is registered in the Hue portal and returned from the discovery endpoint that is queried but cannot be +connected to for any reason (i.e. it is offline), then the bridge data will be provided in an error object of the form: + +```json +{ + "error": { + "message": "An error message", + "description": "Failed to connect and load configuration from the bridge at ip address xxx.xxx.xxx.xxx", + "ipaddress": "xxx.xxx.xxx.xxx", + "id": "xxxxxxxxxxxxxxxx" + } +} +``` + The `message` value will be that of the underlying error when attempting to resolve the bridge configuration. The `id` + is the mac address reported from the discovery portal and the `ipaddress` is that of the recorded ip address from the + discovery portal. ## UPnP Search diff --git a/index.js b/index.js index c94f20b..b9c0e05 100644 --- a/index.js +++ b/index.js @@ -5,11 +5,13 @@ // const v3 = require('./lib/v3') + , discovery = require('./lib/api/discovery') , ApiError = require('./lib/ApiError') ; module.exports = { v3: v3, + discovery: discovery, // This was present in the old API, may need to deprecate it ApiError: ApiError, diff --git a/lib/api/discovery/index.js b/lib/api/discovery/index.js index 152615b..6ff2525 100644 --- a/lib/api/discovery/index.js +++ b/lib/api/discovery/index.js @@ -36,7 +36,18 @@ function loadDescriptions(results) { function loadConfigurations(results) { const promises = results.map(result => { - return bridgeValidator.getBridgeConfig(result); + return bridgeValidator + .getBridgeConfig(result) + .catch(err => { + return { + error: { + message: err.message, + description: `Failed to connect and load configuration from the bridge at ip address ${result.ipaddress}`, + ipaddress: result.internalipaddress, + id: result.id, + } + }; + }); }); return Promise.all(promises); diff --git a/lib/api/discovery/index.test.js b/lib/api/discovery/index.test.js index 91ca5f8..16a6473 100644 --- a/lib/api/discovery/index.test.js +++ b/lib/api/discovery/index.test.js @@ -17,10 +17,8 @@ describe('discovery', () => { expect(results[0]).to.have.property('name'); expect(results[0]).to.have.property('ipaddress'); - expect(results[0]).to.have.property('model'); - expect(results[0].model).to.have.property('name'); - expect(results[0].model).to.have.property('number'); - expect(results[0].model).to.have.property('serial'); + expect(results[0]).to.have.property('modelid'); + expect(results[0]).to.have.property('swversion'); }); }); diff --git a/lib/v3.js b/lib/v3.js index 75956e9..adb048e 100644 --- a/lib/v3.js +++ b/lib/v3.js @@ -4,12 +4,39 @@ const api = require('./api/index') , discovery = require('./api/discovery/index') , bridgeModel = require('./model') , ApiError = require('./ApiError') + , util = require('./util') ; // Definition of the v3 API for node-hue-api module.exports = { api: api, - discovery: discovery, + + discovery: { + upnpSearch: (timeout) => { + util.deprecatedFunction( + '6.x', + `require('node-hue-api').v3.discovery.upnpSearch()`, + `Use require('node-hue-api').discovery.upnpSearch()`); + return discovery.upnpSearch(timeout); + }, + + nupnpSearch: () => { + util.deprecatedFunction( + '6.x', + `require('node-hue-api').v3.discovery.nupnpSearch()`, + `Use require('node-hue-api').discovery.nupnpSearch()`); + return discovery.nupnpSearch(); + }, + + description: (ipAddress) => { + util.deprecatedFunction( + '6.x', + `require('node-hue-api').v3.discovery.description(ipAddress)`, + `Use require('node-hue-api').discovery.description(ipAddress)`); + return discovery.description(ipAddress); + }, + }, + //TODO think about removing this and deferring to the model lightStates: bridgeModel.lightStates, diff --git a/package.json b/package.json index 5351f3d..2097236 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "node-hue-api", "description": "Philips Hue API Library for Node.js", "version": "4.0.5", - "author": "Peter Murray ", + "author": "Peter Murray <681306+peter-murray@users.noreply.github.com>", "contributors": [ { "name": "Peter Murray", From c3144dc6c97c10c074c9d059f4bacfb47229a8ca Mon Sep 17 00:00:00 2001 From: Peter Murray <681306+peter-murray@users.noreply.github.com> Date: Mon, 9 Mar 2020 11:52:26 +0000 Subject: [PATCH 03/13] 5.0.0-alpha.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 46b95d9..de61a4d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "node-hue-api", - "version": "4.0.5", + "version": "5.0.0-alpha.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2097236..3f0957c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "node-hue-api", "description": "Philips Hue API Library for Node.js", - "version": "4.0.5", + "version": "5.0.0-alpha.1", "author": "Peter Murray <681306+peter-murray@users.noreply.github.com>", "contributors": [ { From 54e2e624f91272c2c5c48736f4f358f7f7f80b0b Mon Sep 17 00:00:00 2001 From: Peter Murray Date: Fri, 24 Apr 2020 08:07:33 +0100 Subject: [PATCH 04/13] Typo in one of the choice settings for bridge configuration update status, fixes #170 --- lib/model/BridgeConfiguration.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/model/BridgeConfiguration.js b/lib/model/BridgeConfiguration.js index 6acdb7e..ac9f228 100644 --- a/lib/model/BridgeConfiguration.js +++ b/lib/model/BridgeConfiguration.js @@ -33,7 +33,7 @@ const ATTRIBUTES = [ 'noupdates', 'transferring', 'anyreadytoinstall', - 'allreadtoinstall', + 'allreadytoinstall', 'installing', ] }), From e21f061600cd45b823aadd01c7ab7cb88fc546ee Mon Sep 17 00:00:00 2001 From: Peter Murray Date: Fri, 24 Apr 2020 08:09:39 +0100 Subject: [PATCH 05/13] Fixing dev dependency security audit warnings --- .../v3/capabilities/getAllCapabilities.js | 8 +- examples/v3/discoverAndCreateUserScript.js | 5 +- examples/v3/discoverBridgeViaNupnp.js | 4 +- examples/v3/discoverBridgeViaUpnp.js | 4 +- examples/v3/lights/getLight.js | 2 +- package-lock.json | 194 +++++++++++------- package.json | 4 +- 7 files changed, 129 insertions(+), 92 deletions(-) diff --git a/examples/v3/capabilities/getAllCapabilities.js b/examples/v3/capabilities/getAllCapabilities.js index 33a73db..c305110 100644 --- a/examples/v3/capabilities/getAllCapabilities.js +++ b/examples/v3/capabilities/getAllCapabilities.js @@ -1,16 +1,16 @@ 'use strict'; -const v3 = require('../../../index').v3; +const hueApi = require('../../../index'); // If using this code outside of this library the above should be replaced with -// const v3 = require('node-hue-api').v3; +// const hueApi = require('node-hue-api'); // Replace this with your username for accessing the bridge const USERNAME = require('../../../test/support/testValues').username; -v3.discovery.nupnpSearch() +hueApi.discovery.nupnpSearch() .then(searchResults => { const host = searchResults[0].ipaddress; - return v3.api.createLocal(host).connect(USERNAME); + return hueApi.v3.api.createLocal(host).connect(USERNAME); }) .then(api => { return api.capabilities.getAll(); diff --git a/examples/v3/discoverAndCreateUserScript.js b/examples/v3/discoverAndCreateUserScript.js index 35f2972..f44a862 100644 --- a/examples/v3/discoverAndCreateUserScript.js +++ b/examples/v3/discoverAndCreateUserScript.js @@ -1,7 +1,8 @@ const v3 = require('../../index').v3 + , discovery = require('../../index').discovery // If using this code outside of the examples directory, you will want to use the line below and remove the // const v3 = require('node-hue-api').v3 - , discovery = v3.discovery + // const discovery = require('node-hue-api').discovery , hueApi = v3.api ; @@ -42,7 +43,7 @@ async function discoverAndCreateUser() { const authenticatedApi = await hueApi.createLocal(ipAddress).connect(createdUser.username); // Do something with the authenticated user/api - const bridgeConfig = await authenticatedApi.configuration.get(); + const bridgeConfig = await authenticatedApi.configuration.getConfiguration(); console.log(`Connected to Hue Bridge: ${bridgeConfig.name} :: ${bridgeConfig.ipaddress}`); } catch(err) { diff --git a/examples/v3/discoverBridgeViaNupnp.js b/examples/v3/discoverBridgeViaNupnp.js index e5147a7..0a60ed8 100644 --- a/examples/v3/discoverBridgeViaNupnp.js +++ b/examples/v3/discoverBridgeViaNupnp.js @@ -1,13 +1,13 @@ 'use strict'; -const v3 = require('../../index').v3 +const discovery = require('../../index').discovery ; // For this to work properly you need to be connected to the same network that the Hue Bridge is running on. // It will not function across VLANs or different network ranges. async function getBridge() { - const results = await v3.discovery.nupnpSearch(); + const results = await discovery.nupnpSearch(); // Results will be an array of bridges that were found console.log(JSON.stringify(results, null, 2)); diff --git a/examples/v3/discoverBridgeViaUpnp.js b/examples/v3/discoverBridgeViaUpnp.js index 4d244fc..28a5f25 100644 --- a/examples/v3/discoverBridgeViaUpnp.js +++ b/examples/v3/discoverBridgeViaUpnp.js @@ -1,10 +1,10 @@ 'use strict'; -const v3 = require('../../index').v3 +const discovery = require('../../index').discovery ; async function getBridge() { - const results = await v3.discovery.upnpSearch(); + const results = await discovery.upnpSearch(); // Results will be an array of bridges that were found console.log(JSON.stringify(results, null, 2)); diff --git a/examples/v3/lights/getLight.js b/examples/v3/lights/getLight.js index e66650e..15b3658 100644 --- a/examples/v3/lights/getLight.js +++ b/examples/v3/lights/getLight.js @@ -16,7 +16,7 @@ v3.discovery.nupnpSearch() return v3.api.createLocal(host).connect(USERNAME); }) .then(api => { - return api.lights.get(LIGHT_ID); + return api.lights.getLight(LIGHT_ID); }) .then(light => { // Display the details of the light diff --git a/package-lock.json b/package-lock.json index de61a4d..18c216c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,9 +25,9 @@ } }, "acorn": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", - "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==", + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz", + "integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==", "dev": true }, "acorn-jsx": { @@ -97,12 +97,11 @@ "dev": true }, "axios": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz", - "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", + "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", "requires": { - "follow-redirects": "1.5.10", - "is-buffer": "^2.0.2" + "follow-redirects": "1.5.10" } }, "balanced-match": { @@ -337,21 +336,22 @@ "dev": true }, "es-abstract": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.16.0.tgz", - "integrity": "sha512-xdQnfykZ9JMEiasTAJZJdMWCQ1Vm00NBw79/AWi7ELfZuuPCSOMDZbT9mkOfSctVtfhb+sAAzrm+j//GjjLHLg==", + "version": "1.17.5", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.5.tgz", + "integrity": "sha512-BR9auzDbySxOcfog0tLECW8l28eRGpDpU3Dm3Hp4q/N+VtLTmyj4EUN088XZWQDW/hzj6sYRDXeOFsaAODKvpg==", "dev": true, "requires": { - "es-to-primitive": "^1.2.0", + "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", "has": "^1.0.3", - "has-symbols": "^1.0.0", - "is-callable": "^1.1.4", - "is-regex": "^1.0.4", - "object-inspect": "^1.6.0", + "has-symbols": "^1.0.1", + "is-callable": "^1.1.5", + "is-regex": "^1.0.5", + "object-inspect": "^1.7.0", "object-keys": "^1.1.1", - "string.prototype.trimleft": "^2.1.0", - "string.prototype.trimright": "^2.1.0" + "object.assign": "^4.1.0", + "string.prototype.trimleft": "^2.1.1", + "string.prototype.trimright": "^2.1.1" } }, "es-to-primitive": { @@ -774,20 +774,21 @@ } }, "is-buffer": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", - "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", + "dev": true }, "is-callable": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", - "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", + "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", "dev": true }, "is-date-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", - "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", + "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", "dev": true }, "is-fullwidth-code-point": { @@ -803,21 +804,21 @@ "dev": true }, "is-regex": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", - "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", + "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", "dev": true, "requires": { - "has": "^1.0.1" + "has": "^1.0.3" } }, "is-symbol": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", - "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", + "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", "dev": true, "requires": { - "has-symbols": "^1.0.0" + "has-symbols": "^1.0.1" } }, "isexe": { @@ -905,24 +906,24 @@ } }, "minimist": { - "version": "0.0.8", - "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "dev": true }, "mkdirp": { - "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", "dev": true, "requires": { - "minimist": "0.0.8" + "minimist": "^1.2.5" } }, "mocha": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.2.2.tgz", - "integrity": "sha512-FgDS9Re79yU1xz5d+C4rv1G7QagNGHZ+iXF81hO8zY35YZZcLEsJVfFolfsqKFWunATEvNzMK0r/CwWd/szO9A==", + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-6.2.3.tgz", + "integrity": "sha512-0R/3FvjIGH3eEuG17ccFPk117XL2rWxatr81a57D+r/x2uTYZRbdZ4oVidEUMh2W2TJDa7MdAb12Lm2/qrKajg==", "dev": true, "requires": { "ansi-colors": "3.2.3", @@ -937,7 +938,7 @@ "js-yaml": "3.13.1", "log-symbols": "2.2.0", "minimatch": "3.0.4", - "mkdirp": "0.5.1", + "mkdirp": "0.5.4", "ms": "2.1.1", "node-environment-flags": "1.0.5", "object.assign": "4.1.0", @@ -945,8 +946,8 @@ "supports-color": "6.0.0", "which": "1.3.1", "wide-align": "1.1.3", - "yargs": "13.3.0", - "yargs-parser": "13.1.1", + "yargs": "13.3.2", + "yargs-parser": "13.1.2", "yargs-unparser": "1.6.0" }, "dependencies": { @@ -973,6 +974,21 @@ "path-is-absolute": "^1.0.0" } }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "mkdirp": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.4.tgz", + "integrity": "sha512-iG9AK/dJLtJ0XNgTuDbSyNS3zECqDlAhnQW4CsNxBG3LQJBbHmRX1egw39DmtOdCAqY+dKXV+sgPgilNWUKMVw==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, "ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", @@ -1021,14 +1037,6 @@ "requires": { "object.getownpropertydescriptors": "^2.0.3", "semver": "^5.7.0" - }, - "dependencies": { - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } } }, "object-inspect": { @@ -1056,13 +1064,13 @@ } }, "object.getownpropertydescriptors": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz", - "integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.0.tgz", + "integrity": "sha512-Z53Oah9A3TdLoblT7VKJaTDdXdT+lQO+cNpKVnya5JDe9uLvzu1YyY1yFDFrcxrlRgWrEFH0jJtD/IbuwjcEVg==", "dev": true, "requires": { - "define-properties": "^1.1.2", - "es-abstract": "^1.5.1" + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" } }, "once": { @@ -1104,9 +1112,9 @@ "dev": true }, "p-limit": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", - "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", "dev": true, "requires": { "p-try": "^2.0.0" @@ -1251,6 +1259,12 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", @@ -1305,24 +1319,46 @@ "strip-ansi": "^4.0.0" } }, + "string.prototype.trimend": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", + "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } + }, "string.prototype.trimleft": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.0.tgz", - "integrity": "sha512-FJ6b7EgdKxxbDxc79cOlok6Afd++TTs5szo+zJTUyow3ycrRfJVE2pq3vcN53XexvKZu/DJMDfeI/qMiZTrjTw==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.2.tgz", + "integrity": "sha512-gCA0tza1JBvqr3bfAIFJGqfdRTyPae82+KTnm3coDXkZN9wnuW3HjGgN386D7hfv5CHQYCI022/rJPVlqXyHSw==", "dev": true, "requires": { "define-properties": "^1.1.3", - "function-bind": "^1.1.1" + "es-abstract": "^1.17.5", + "string.prototype.trimstart": "^1.0.0" } }, "string.prototype.trimright": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.0.tgz", - "integrity": "sha512-fXZTSV55dNBwv16uw+hh5jkghxSnc5oHq+5K/gXgizHwAvMetdAJlHqqoFC1FSDVPYWLkAKl2cxpUT41sV7nSg==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.2.tgz", + "integrity": "sha512-ZNRQ7sY3KroTaYjRS6EbNiiHrOkjihL9aQE/8gfQ4DtAC/aEBRHFJa44OmoWxGGqXuJlfKkZW4WcXErGr+9ZFg==", "dev": true, "requires": { "define-properties": "^1.1.3", - "function-bind": "^1.1.1" + "es-abstract": "^1.17.5", + "string.prototype.trimend": "^1.0.0" + } + }, + "string.prototype.trimstart": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", + "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" } }, "strip-ansi": { @@ -1531,9 +1567,9 @@ "dev": true }, "yargs": { - "version": "13.3.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", - "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", + "version": "13.3.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.2.tgz", + "integrity": "sha512-AX3Zw5iPruN5ie6xGRIDgqkT+ZhnRlZMLMHAs8tg7nRruy2Nb+i5o9bwghAogtM08q1dpr2LVoS8KSTMYpWXUw==", "dev": true, "requires": { "cliui": "^5.0.0", @@ -1545,7 +1581,7 @@ "string-width": "^3.0.0", "which-module": "^2.0.0", "y18n": "^4.0.0", - "yargs-parser": "^13.1.1" + "yargs-parser": "^13.1.2" }, "dependencies": { "ansi-regex": { @@ -1577,9 +1613,9 @@ } }, "yargs-parser": { - "version": "13.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", - "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "version": "13.1.2", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz", + "integrity": "sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg==", "dev": true, "requires": { "camelcase": "^5.0.0", diff --git a/package.json b/package.json index 3f0957c..7ab3b33 100644 --- a/package.json +++ b/package.json @@ -28,14 +28,14 @@ "url": "https://github.com/peter-murray/node-hue-api/issues" }, "dependencies": { - "axios": "^0.19.0", + "axios": "^0.19.2", "bottleneck": "^2.19.5", "get-ssl-certificate": "^2.3.3" }, "devDependencies": { "chai": "~4.2", "eslint": "^5.16.0", - "mocha": "~6.2.2" + "mocha": "^6.2.3" }, "engines": { "node": ">= 10.0.0" From 1badee1a6fb8b872cc5629a3b6611559a366ca50 Mon Sep 17 00:00:00 2001 From: Peter Murray Date: Fri, 24 Apr 2020 08:20:25 +0100 Subject: [PATCH 06/13] - Updating tests to remove deprecations and old invalid user data --- lib/api/Users.test.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/api/Users.test.js b/lib/api/Users.test.js index 3c96750..e4226ed 100644 --- a/lib/api/Users.test.js +++ b/lib/api/Users.test.js @@ -2,7 +2,7 @@ const expect = require('chai').expect , v3Api = require('../v3').api - , discovery = require('../v3').discovery + , discovery = require('../../index').discovery , ApiError = require('../../index').ApiError , testValues = require('../../test/support/testValues.js') //TODO move these ; @@ -69,7 +69,7 @@ describe('Hue API #users', () => { // }); it('should remove test accounts', async () => { - const users = await authenticatedHue.users.getByName('node-hue-api', 'node-hue-api-tests'); + const users = await authenticatedHue.users.getUserByName('node-hue-api', 'node-hue-api-tests'); expect(users).to.be.instanceof(Array); expect(users).to.have.length.greaterThan(0); @@ -107,7 +107,7 @@ describe('Hue API #users', () => { describe('#get()', () => { it('should get a user by username', async () => { - const user = await authenticatedHue.users.get(testValues.username); + const user = await authenticatedHue.users.getUser(testValues.username); expect(user).to.have.property('username').to.equal(testValues.username); expect(user).to.have.property('name'); @@ -116,7 +116,7 @@ describe('Hue API #users', () => { }); it('should not find an invalid username', async () => { - const user = await authenticatedHue.users.get(testValues.username + '0000'); + const user = await authenticatedHue.users.getUser(testValues.username + '0000'); expect(user).to.be.null; }); @@ -126,7 +126,7 @@ describe('Hue API #users', () => { describe('#getByName()', () => { it('should get a list of user accounts for valid name', async () => { - const username = 'Echo' + const username = 'Indigo Hue Lights' //TODO hardcoded value, pull this out into test data , users = await authenticatedHue.users.getUserByName(username) ; @@ -141,8 +141,8 @@ describe('Hue API #users', () => { it('should get a list of user accounts for appName, deviceName', async () => { const appName = 'node-hue-api' - , deviceName = 'my-device' - , users = await authenticatedHue.users.getByName(appName, deviceName) + , deviceName = 'example-code' //TODO hardcoded value, pull this out into test data + , users = await authenticatedHue.users.getUserByName(appName, deviceName) ; expect(users).to.be.instanceof(Array); @@ -154,7 +154,7 @@ describe('Hue API #users', () => { }); it('should not find a account that does not exist', async () => { - const users = await authenticatedHue.users.getByName('0000000001'); + const users = await authenticatedHue.users.getUserByName('0000000001'); expect(users).to.be.instanceOf(Array); expect(users).to.be.empty; From 61833a5137de85665daa5bb98adfd90ab47a9c83 Mon Sep 17 00:00:00 2001 From: Peter Murray Date: Fri, 24 Apr 2020 08:21:24 +0100 Subject: [PATCH 07/13] - Updating test as bridge update has changed the manufacturer name string in the sensor --- lib/api/Sensors.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/Sensors.test.js b/lib/api/Sensors.test.js index e0e9f78..2b4f1b5 100644 --- a/lib/api/Sensors.test.js +++ b/lib/api/Sensors.test.js @@ -51,7 +51,7 @@ describe('Hue API #sensors', () => { expect(sensors[0]).to.have.property('name', 'Daylight'); expect(sensors[0]).to.have.property('type', 'Daylight'); expect(sensors[0]).to.have.property('modelid', 'PHDL00'); - expect(sensors[0]).to.have.property('manufacturername', 'Philips'); + expect(sensors[0]).to.have.property('manufacturername', 'Signify Netherlands B.V.'); expect(sensors[0]).to.have.property('swversion', '1.0'); }); }); From 290fb2894593dce3483bd10c1cda6297d37dd8da Mon Sep 17 00:00:00 2001 From: Peter Murray Date: Fri, 24 Apr 2020 08:31:51 +0100 Subject: [PATCH 08/13] - Updating tests to remove test value data requirements --- lib/api/discovery/index.test.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/api/discovery/index.test.js b/lib/api/discovery/index.test.js index 16a6473..ad8992d 100644 --- a/lib/api/discovery/index.test.js +++ b/lib/api/discovery/index.test.js @@ -2,7 +2,6 @@ const expect = require('chai').expect , discovery = require('./index') - , testValues = require('../../../test/support/testValues') ; describe('discovery', () => { @@ -48,10 +47,17 @@ describe('discovery', () => { this.timeout(10000); + let hostAddress; + + before(async() => { + const results = await discovery.nupnpSearch(); + expect(results).to.have.length.greaterThan(0); + hostAddress = results[0].ipaddress; + }); + it('should discover a bridge', async () => { - const result = await discovery.description(testValues.host); + const result = await discovery.description(hostAddress); - console.log(JSON.stringify(result, null, 2))//TODO remove expect(result).to.have.property('name'); expect(result).to.have.property('ipaddress'); From 1d08516ddc339a8cc86b80073408f4e0336b9162 Mon Sep 17 00:00:00 2001 From: Peter Murray Date: Fri, 24 Apr 2020 08:32:23 +0100 Subject: [PATCH 09/13] - Adding better error handling/validation for the description() function. --- lib/api/discovery/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/api/discovery/index.js b/lib/api/discovery/index.js index 6ff2525..fcc6fe2 100644 --- a/lib/api/discovery/index.js +++ b/lib/api/discovery/index.js @@ -3,6 +3,7 @@ const UPnP = require('./UPnP') , nupnp = require('./nupnp') , bridgeValidator = require('./bridge-validation') + , ApiError = require('../../../').ApiError ; @@ -17,6 +18,10 @@ module.exports.nupnpSearch = function () { }; module.exports.description = function (ipAddress) { + if (! ipAddress) { + throw new ApiError(`A bridge ip address must be provided`); + } + return loadDescriptions([{internalipaddress: ipAddress}]) .then(results => { if (results) { From 2494322634ac95068ce7f6c7c54828a9972a8e8c Mon Sep 17 00:00:00 2001 From: Peter Murray Date: Fri, 24 Apr 2020 14:02:24 +0100 Subject: [PATCH 10/13] 5.0.0-alpha.2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 18c216c..63b70f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "node-hue-api", - "version": "5.0.0-alpha.1", + "version": "5.0.0-alpha.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7ab3b33..05b400c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "node-hue-api", "description": "Philips Hue API Library for Node.js", - "version": "5.0.0-alpha.1", + "version": "5.0.0-alpha.2", "author": "Peter Murray <681306+peter-murray@users.noreply.github.com>", "contributors": [ { From 0c250585b95711469b0b668cefa1cd1fe559bc88 Mon Sep 17 00:00:00 2001 From: Peter Murray Date: Wed, 13 May 2020 17:42:55 +0100 Subject: [PATCH 11/13] Adding Apache 2.0 license file --- LICENSE | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From f982706878035fb67dada7989d5c5a6700828427 Mon Sep 17 00:00:00 2001 From: Peter Murray Date: Fri, 22 May 2020 12:22:34 +0100 Subject: [PATCH 12/13] Create code scanning workflow --- .github/workflows/codeql-analysis.yml | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..39b2534 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,42 @@ +name: "Code scanning - action" + +on: + push: + schedule: + - cron: '0 10 * * 4' + +jobs: + CodeQL-Build: + + # CodeQL runs on ubuntu-latest and windows-latest + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + # Override language selection by uncommenting this and choosing your languages + # with: + # languages: go, javascript, csharp, python, cpp, java + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From eaf3c888a464df80a76ccca49eba42902c93d45a Mon Sep 17 00:00:00 2001 From: Peter Murray Date: Sun, 31 May 2020 15:32:52 +0100 Subject: [PATCH 13/13] Related to #172, changing ordering in case of success to ensure that references to state are correctly set before clearing promise reference and displaying error message if the async request fails --- lib/api/Api.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/api/Api.js b/lib/api/Api.js index 432d4fb..8ad4d24 100644 --- a/lib/api/Api.js +++ b/lib/api/Api.js @@ -165,11 +165,12 @@ module.exports = class Api { } self._syncPromise = self._syncPromise.then(data => { - self._syncPromise = null; self._state = new Cache(data); self._lastSyncTime = new Date().getTime(); + self._syncPromise = null; }) - .catch(() => { + .catch(err => { + console.error(`Failed to async load the bridge configuration data; ${err}`); self._syncPromise = null; }); }