Commit Graph
76 Commits
Author SHA1 Message Date
Sulka HaroandGitHub 82f00763d6 Move app caching to a service worker (#5504)
* Move app caching to a webworker

* Code cleanup

* Code cleanup

* Make Codacy happy

* More parentheses
2020-02-05 08:16:25 +02:00
Bartłomiej SzubertandSulka Haro ddbda15c0a Move toolbar and authentication status to partial and include on each page (#5393)
* Move authentication status to partial and include on each page

* Move toolbar to partial

Co-authored-by: Sulka Haro <sulka@sulka.net>
2020-01-06 19:31:03 +02:00
Sulka HaroandGitHub 04b47f6109 Add 4 hour option to view (#5289)
* Revert "change default back to 3HR"

This reverts commit e60ff3aa9d.

* shorten HR to H to avoid line-wrapping on mobile

* try larger label font: 35 instead of 25 (vs. 40)

* add comma

* deviceInfo.recent null check

* default back to 3, w/ 4 as an option

* re-add H to single-digit hours

* * Don't use cache manifest all all for development
* Add 4 hours option to view and change the labelling to remove language issues
* Have page scale the minor pill widths more gracefully
2019-12-14 16:07:47 +00:00
PetrOndrusek 5c5821a90d adding list of supported APIs versions (GET /api/versions) 2019-10-30 22:55:23 +01:00
Pete SchwambandSulka Haro d729b0eb00 Remote Loop overrides (#5043)
* skeleton code

* publishing

* Activating remote override

* Fix event types refresh, and fix custom duration

* Don't create treatment record; loop will

* Additional override details for treatment tooltip

* Pass client from careportal

* attempt at moving endpoint to api/v2

* Add bodyParser to v2/notifications

* Remove notifications api from v1

* Remove unused var

* Better error handling and reporting

* Add documentation for new loop plugin vars

* Handle indefinite duration overrides

* Move label of indeterminate duration override to now line when start is offscreen

* test

* Use separate representation for indefinite duration treatments

* fix display for finite duration treatments

* Fix re-use of elements when treatment ordering changes

* Handle more rect transition() updates

* Add check for LOOP_DEVELOPER_TEAM_ID

* Support configuration of aps-environment via environment variable.

* Fix expiration date math; was essentially preventing retries
2019-10-16 12:35:22 +03:00
Petr OndrusekandSulka Haro 2dd576a629 API V3 (#4250)
* extended .gitignore for Visual Studio 2017

* creating a lib for api3 and exposing it's swagger file

* adding pilot test (for /swagger.yaml)

* implementing public GET /version

* setting api version to 3.0.0-alpha

* creating authorization skeleton + fetching some API env variables

* reusing authorization library

* implementing security

* forcing HTTPS and removing x-powered-by from response

* moving messages to constants, creating https instance fixture

* testing HTTPS requiring

* testing Date header

* testing permission check

* testing allowed operation

* refactoring + storage stub

* create architecture for generic operations

* beginning of READ operation

* tidying the code up

* basic READ part

* going further with READ operation

* DELETE operation

* handling fields parameter

* refactoring to classes

* going further with SEARCH operation

* refactoring file structure

* filtering for SEARCH operation

* preparations for fallback deduplication

* CREATE operation

* UPDATE operation

* PATCH operation

* HISTORY operation

* creating more precise variant of HISTORY operation

* autopruning

* long for timestamps in swagger

* bug fix (when search fields=srvCreated)

* creating skeleton for generic collection API test

* specific HISTORY skeleton

* distinguish between collection logical and storage name

* renaming operation to LAST MODIFIED and getting it to work

* fallback for LAST MODIFIED operation

* tidying a bit

* LAST MODIFIED documentation

* bugfix + emitting data-received

* adding some validations

* bugfix - remove 'token' parameter from filtering

* testing and debugging generic workflow

* test fix for empty db

* fixing security test fixture

* trying to fix Travis CI testing DB problem

* multiple auth callback bugfix + adding user field on authed create/update

* messages for Travis CI debugging

* messages for Travis CI debugging

* messages for Travis CI debugging

* test fix (to be prepared for future dates in db)

* test fix

* adding fallback created_at filling on each create/update

* STATUS operation with API permissions

* querying srvDate from storage + include storage version info

* bugfix of missing apiConst require

* getting mongo version with read-only user rights

* getting mongo current date with read-only user rights

* trying to diagnose travis CI timeout

* refactoring storage version caching (due to some environments problems)

* making VERSION work on empty database

* more fixes

* skipping API HTTPS test for node 8

* making code more readable using ES6 (Promises, async + await)

* extending treatments collection docs by inspecting the careportal code

* tidying existing API3 tests up to allow further grow

* tidying the authorization code up to increase readability and performance a bit

* more refactoring to ES6 and making APIv3 files structure more extendable

* normalizing incoming dates to UTC and storing utcOffset

* fixing srvDate to be of node.js server, not the mongo DB

* preparing test fixtures for permissions testing + skeleton for CREATE operation test

* intensive CREATE operation testing + minor bug fixes

* correcting the deduplication test

* more deduplication testing of CREATE operation

* adding test skeletons for other generic operations

* added variability in filtering by date, created_at, srvModified, srvCreated fields

* fixing test accordingly to previous commit

* adding new collection settings for centralized apps' settings storage

* trying to solve travis CI testing problem - adding default collections names

* another attempt to travis CI test fix

* adding some tests for READ operation

* adding custom error handler (overriding bodyparser's errors)

* securing settings collection more and updating swagger accordingly

* making HISTORY timestamp parameter more flexible + updating swagger documentation

* more testing and bug fixing

* sending only HTTP status with empty body, when there is no message + minor bug fixing

* more refactoring and testing (especially of UPDATE operation)

* PATCH testing + adding userModified field for troubleshooting purposes

* basic SEARCH operation testing

* more SEARCH operation testing

* adding alternative 'now' query parameter to 'Date' header to make GET easier

* adding 'now' to reserved query parameters for SEARCH operation

* more testing

* renaming field user to subject (and modifiedBy)

* bugfix - fixing RFC 2822 constant for moment parsing

* storageSocket: creating skeleton for new Socket.IO namespace

* storageSocket: authentication by accessToken

* storageSocket: authorizing to subscribe rooms

* storageSocket: emitting create, update and delete events

* APIv3: adding support for swagger UI at /api/v3/swagger-ui-dist

* solving some problems detected by eslint

* solving some problems detected by eslint

* APIv3: testing and debugging Socket.IO

* APIv3: testing and debugging Socket.IO

* APIv3: Socket.IO documentation

* APIv3: making the sample real

* APIv3: starting to create a simple tutorial MD file

* APIv3: small corrections

* APIv3: minor corrections after dev merge

* APIv3: adding CREATE and READ operations to the tutorial.md

* APIv3: adding SEARCH, LAST MODIFIED, UPDATE operations to the tutorial.md

* APIv3: finishing the tutorial.md

* APIv3: minor bugfix (bad location after upsert)

* APIv3: refactoring SEARCH complexity

* APIv3: refactoring mongoCollection complexity

* APIv3: refactoring complexity

* APIv3: tidying up a bit

* APIv3: refactoring security (start)

* APIv3: refactoring lastModified

* APIv3: refactoring create (start)

* APIv3: refactoring create (finish)

* APIv3: refactoring delete

* APIv3: refactoring history

* APIv3: refactoring update

* APIv3: refactoring patch

* APIv3: refactoring read

* APIv3: refactoring search + removing deprecated authorizationBuilder

* APIv3: adding best practise for identifier constructing

* APIv3: refactoring and enhancing the validation (immutable fields)

* APIv3: adding security.md documentation file

* APIv3: refactoring - splitting index.js into multiple files

* APIv3: calculating identifier on server side + deduplicating

* APIv3: refactoring cosmetics

* APIv3: updating the documentation

* APIv3: making basic and security tests more readable using async/await

* APIv3: making the rest of tests more readable using async/await

* APIv3: adapting test of previous API

* APIv3: adapting test of previous API
2019-10-09 22:53:55 +03:00
PieterGitandGitHub d0e14de83d Fix clock if authentication is enabled (#4914)
* Fix clock if authentication is enabled
Add .npmignore file

* Add time to clock view back

* Formatting

* Select browser language for authentication dialog
Make authentication dialog bigger to suit for other languages.

* Update hashauth.js

* Update hashauth.js

* Update hashauth.js

* Update hashauth.js

* Select language from localStorage

And get suitable language for the very first auth dialog (before the settings were read from server or user can select language in the configuration)

* remove extra `/ ` from clockview, otherwise bundle will not load and search for domain `bundle`

fixes https://github.com/nightscout/cgm-remote-monitor/pull/4860#pullrequestreview-277209223

* remove .npmignore for now.

should be merged in seperated PR

* small fixes
2019-08-22 20:50:51 +02:00
BluefoxandGitHub 1c9d5b1409 Use not only from cgm-remote-monitor 2019-08-03 21:22:14 +02:00
BluefoxandGitHub 5e883886ee Formatting 2019-08-03 21:18:54 +02:00
BluefoxandGitHub 54ae531528 Allow start nightscout from other directories but cgm-remote-monitor
If I start nightscout from other path, e.g. from `/opt` and nightscout is in `/opt/cgm-remote-monitor`, it tries to find `/opt/tmp` what does not exist.
2019-08-03 21:06:25 +02:00
Sulka HaroandGitHub 7947e30071 feat: API improvements (#4806)
* Use moment.js to parse dates, with better error messaging for unparseable dates

* Oops fix a bug here

* Add logging for unparseable dates

* Output a better error

* * Re-enabled heap dumps
* Improved API documentation
2019-07-29 17:20:49 +03:00
Benedikt BauerandGitHub 7f5f74c8ca Perform HTTP to HTTPS redirect using 307 status
302 and 307 basically do the same thing with just one important difference:
The default 302 redirect from express.js tells the browser to repeat the request with the new URL using the GET verb.
When using the 307 status code manually, this tells the browser to repeat the very same request against the new URL using all the same parameters, headers and most important HTTP verbs.

In practice this is important every time you want to change settings or flip a switch or enter your API key (that information will never arrive at the server)
It's even more important when you get to the site through a reverse proxy that doesn't properly set the X-Forwarded-Proto header.
2019-07-22 22:01:19 +02:00
Sulka Haro f874183959 BUGFIX: Fix the clock to load the javascript bundle from the right place 2019-07-20 13:53:05 +03:00
Sulka Haro 851b08ff4c Fix issues found with linting in the server code & update module versions based on npm audit 2019-07-19 09:46:40 +03:00
Sulka Haro e9576df740 Add documentation 2019-07-15 13:22:01 +03:00
Sulka Haro 8653d492f2 * Package reporting plugins separately into another bundle to reduce main bundle size
* Use moment timezone webpack plugin to load less time zone data
* When server is run in development mode, hot reload code changes without restart
2019-06-30 20:58:04 +03:00
Sulka HaroandGitHub 6ed5ee0ec0 feat: clock view code refactor (#4639)
* * Full refactor of the clockface code. Clocks now get their own small javascript bundle that contains the bare minimum client (from /lib/client/clock-client.js)
* Clocks no longer have separate HTML files but each has unique CSS definitions
* Fixed the bug where a finger measurement showed NaN in the clock

* Update shrinkwrap to match package.json

* Revert accidental index.html changes

* Bunch of minor fixes (#4641)

* Add triple arrows

* remove time

* grey arrows on bgclock

* try again on arrow fill

* Update bgclock.css

* fix double-mmol-conversion

* Update clock-client.js

* tabs to spaces everywhere

* Refactors based on Jason's comments

* Remove the clock bundle generation from app.js
2019-06-20 08:55:52 +03:00
Sulka HaroandGitHub 4efc79965b Allow framing in Helmet, as many users have setups like monitoring two PWDs in a frame-based setup, which was broken by the previous release (#4495) 2019-04-28 22:30:38 +03:00
Sulka HaroandPieterGit d73958de1b Fix CSP handling (#4449)
* Change incompatible module and fix a memory leak in the process

* Fix fonts, allow websocket

* Oops fix a brainfart with using the hostname

* Don't inlude null hostname

* Update the shrinkwrap

* Instantiate new cache if new instance of profile code is created. Calculate IOB with three digit precision to keep tests happy (and this is roughly the precision we're operating at anyway).

* - implement @jweismann suggestions https://github.com/nightscout/cgm-remote-monitor/pull/4449#issuecomment-469868508
- add frameAncestors, baseUri and formAction protection

* update README and run doctoc

* fix reportOnly

* add objectSrc

* Use modern CSS loading

* Change CSS to use the "official" async loading across the board (which hopefully plays nicer with CSP)

* first release candiate for 0.11.2 with Minimed EU Server and Guardian Connect integration

- integrates https://github.com/mddub/minimed-connect-to-nightscout/pull/11 into Nightscout

* bump node 10 LTS version

* increase logging, fix /swagger.yaml

* fix typo

* set version to rc2, update mongodb to 3.2.2

* add SECURE_CSP_REPORT_ONLY (default false).

* npm update and revert to requiring Node versions without security issues.
2019-04-06 17:02:05 +02:00
Dave CarlsonandPieterGit db5d8fe2bf cover request.secure in HTTPS redirect exemption (#4483) 2019-03-25 08:21:45 +01:00
Sulka HaroandGitHub 3acd7c8445 Fix auth button ui & update cache busting for App Cache (#4270)
* small doc fix to comments on Node versions

* Update README.md

* * Fixes authentication dialog UI on Mobile Safari
* Improves app cache busting, so after deploy the app is guaranteed to notice it has to reload content
* Small fix to Finnish language related to auth UI
2019-02-07 22:14:34 +02:00
PieterGit ab54f09c7a user correct env 2019-02-03 01:10:02 +01:00
PieterGit a6b98c3939 fix ident and add extra test to env.test.js 2019-02-03 00:56:20 +01:00
PieterGit 6432298986 add missing env 2019-02-02 23:04:25 +01:00
PieterGit 3104083670 fix readENVTruthy and make INSECURE_USE_HTTP, SECURE_HSTS_HEADER, SECURE_HSTS_HEADER_* and SECURE_CSP work as expected.
readENVTruthy never returned defaultValue. if not set to on|off|true|false the default value is returned
2019-02-02 22:29:02 +01:00
PieterGit 87c101acc2 fix version typo and add missing parts of PR 2018-12-26 09:23:25 +01:00
PieterGit 5ac35de7d6 fix INSECURE_USE_HTTP 2018-11-29 00:34:44 +01:00
PieterGit 2b958c9371 npm update, disable Content Security Policy headers for now. Currently Nightscout is not yet compatible with CSP. 2018-11-28 23:25:13 +01:00
PieterGit 5110bc4d86 allow 'unsafe-inline' for stylesSrc and scriptSrc 2018-11-22 00:30:46 +01:00
PieterGit 246ee3c464 test csp 2018-11-22 00:14:31 +01:00
PieterGit 5d4029a4d7 test 2018-11-22 00:09:23 +01:00
PieterGit 90f87e0dc2 redirect by default 2018-11-21 23:53:14 +01:00
PieterGit 4575a65f4a add default for hsts extendsettings 2018-11-21 23:25:49 +01:00
PieterGit ec6fe2c06b improve helmet use 2018-11-21 23:04:24 +01:00
jweismann 372efcac58 add support for HSTS and other security related HTTP headers via helmet 2018-11-05 16:48:16 +01:00
jweismann e180f8fe6e redirect HTTP to HTTPS unless explicitly instructed not to do this redirection 2018-11-04 01:08:59 +01:00
PieterGitandSulka Haro 71103bb4b7 resolve npm audit security fixes (#3721)
* upgrade mocha from 3.5.3 to 5.0.5

This resolves these security issues

  Low             Regular Expression Denial of Service
  Package         debug
  Dependency of   mocha [dev]
  Path            mocha > debug
  More info       https://nodesecurity.io/advisories/534

  Critical        Command Injection
  Package         growl
  Dependency of   mocha [dev]
  Path            mocha > growl
  More info       https://nodesecurity.io/advisories/146

* upgrade mocha and start modularizing lodash to make sure tests pass

* more lodash modularization

* upgrade mqtt to 2.18.3

* allow npm 6.2

* upgrade share2nightscout-bridge

* incorporate express-extension-to-accept into Nightscout

the packages seems not maintained (github page is 404) and has a security issue with mime package.  so upgraded and included into Nightscout code.

if somebody knows a more efficient way of programming this with express4 please PR

* update jsdom for security fixes

* prevent wrapping of hour labels by removing the space

* Revert "update jsdom for security fixes"

This reverts commit 04f1f39d636d8d79c6b01b5f298f9a6cea3dc645.

* Revert "more lodash modularization"

This reverts commit c4fa5304db9f16b94f15c2b44793a5a11d595885.

* remove forever dependency

* Revert "Revert "more lodash modularization""

This reverts commit b13c274ebff0b5c3a48ffc0e610ca85a9f8d25bc.

* fix report.test.js with newer packages

sometimes a fix is very easy. This is to prevent:

```
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments:
[0] _isAMomentObject: true, _isUTC: true, _useUTC: true, _l: undefined, _i: T00:00:00, _f: undefined, _strict: undefined, _locale: [object Object]
Error
    at Function.createFromInputFallback (XXX\cgm-remote-monitor\tmp\js\bundle.js:117408:98)
    at configFromString (XXX\cgm-remote-monitor\tmp\js\bundle.js:119456:15)
```

We must use ISO8601 formatted strings and not use slashes in dates, see https://github.com/moment/moment/issues/1407#issuecomment-155630060

* upgrade webpack to 4.16.2

* Update package.json
2018-07-24 20:25:44 +03:00
PieterGit bc07722a35 Fix booterrors after move it to server dir
This used to work in 0.10.2, but moving booterror to server dir created a bug. Caused by commit https://github.com/nightscout/cgm-remote-monitor/commit/051576056a8cd65ac9459f83cf986080b49431ba#diff-2006a43ba7f8c96ac8368a989f56bd8c
@sulkaharo committed on 27 Dec 2017
2018-07-07 14:01:14 +02:00
Sulka HaroandGitHub 57beae5f10 Activity data collection baseline implementation & swagger fixes (#3442)
* First pass at adding a new activity data collection & API to Nightscout

* Attempt of fixing /api-docs.html
Converted swagger.yaml to OpenAPI 3.0 format using:
https://github.com/Mermade/swagger2openapi
https://mermade.org.uk/openapi-converter
Conversion / Validation engine v2.11.5
Web frontend version v1.3.8

* add swagger-ui-dist and exported swagger.json

* add swagger-config.yaml

* move swagger-ui to static folder, update static/api-docs.html (based on swagger-ui-dist, without bower)

* move swagger.json to static

* add tokenbased authentication

* token based authentication

* add json webtokens for swagger

* npm update, add swagger-ui-dist and expose that to webroot swagger-ui-dist

* remove swagger-config.yaml (not needed)

* Fix swagger and upgrade to openapi3 (and npm update) (#3366)

* fix swagger and upgrade to openapi3, reapply changes of issue https://github.com/nightscout/cgm-remote-monitor/pull/3345

* use nightscout icon for swagger ui

* Comment out deprecated API call
2018-05-07 20:31:01 +03:00
Sulka Haro 48c8e7e537 Fix express-minify file cache path to reduce the memory footprint of the runtime 2017-10-15 10:20:59 +03:00
Sulka Haro 904f80fb03 Testing disabling heap dumps 2017-09-22 11:56:02 +03:00
Sulka Haro fc0bd46946 Move all html files to views folder, update to use the rendered cache buster 2017-09-11 19:49:05 +03:00
Sulka Haro 4d0a3728cc Use ejs to render the app cache and cache buster tokens 2017-08-27 14:34:46 +03:00
Sulka Haro 530df9026f Formatting improvements to app.js 2017-08-23 22:33:45 +03:00
Sulka Haro 918ecc2ed2 Return 404 on app cache request when in development mode, added bold weight Ubuntu 2017-08-23 22:28:21 +03:00
Sulka Haro 76988d6281 Bower is gone 2017-08-16 17:55:04 +03:00
Sulka Haro 9e055ad519 Added missing icons, changed how jQuery and jQuery-UI is packaged 2017-08-16 12:28:52 +03:00
Sulka Haro dbe2927e4c Run packaging in post install instead of runtime 2017-08-15 12:34:25 +03:00
Sulka Haro 6c940a5b24 * Glucose data smoothing / patching before calculating variability to reduce the effects of CGM noise
* Added calculation for GVI, PGS and Total Absolute Change calculation
* Refactored the server to use Webpack for the bundle generation instead of Browserify (since browserify-express seems to not work with Node 8 and is not maintained)
* Improved caching & compression of JS and CSS resources
* If NODE_ENV="development”, don’t cache resources for more than 10 seconds & generate a report about Bundle size
2017-08-11 14:57:53 +03:00
Jason Calabrese 639e52b836 replace all :'s 2017-03-28 17:11:29 -07:00