Giter VIP home page Giter VIP logo

app's Introduction

Project Link app Project Link app

Build Status Documentation Coverage License

An app for Project Link

Support

The following browsers are actively supported:

  • Firefox Nightly for Android
  • Chrome Beta for Android
  • Safari for iOS 9

Prerequisites

Assuming you have git and nvm installed, clone this repo:

$ git clone https://github.com/fxbox/app
$ cd app

And then run:

$ nvm install v4.2.2
$ nvm use v4.2.2
$ npm install -g gulp
$ npm install

How to build?

$ gulp

Then point your browser to https://localhost:8000 and accept security exception for self-signed development certificate.

By default app is served via https using self-signed certificate from certs folder. Certificate is valid for ~100 years and generated with the following command:

$ openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 36500 -nodes

In case custom certificate is required you can either override respective files in certs folder or change certificate and private key paths in webserver gulp task in gulpfile.js.

Even though it's not recommended sometimes you may want to switch to http, for that purpose just comment out https config property in webserver gulp task in gulpfile.js. Check out official gulp-webserver module page for possible options as well. And don't forget to flip it back while running integration tests as they will still assume that app is run via https.

Note: The app is built in the dist/app folder.

Push Notifications

Supported browsers

Firefox 46 Firefox Nightly 49 Chrome 50 Chrome Canary 51 Opera Safari
OSX Working Working Coming soon Coming soon Coming soon Not tested
Linux Working Working Coming soon Coming soon Coming soon
Windows Not tested Not tested Not tested Not tested Not tested
Android Not working Coming soon Coming soon Coming soon Coming soon
iOS Not tested

Prerequisites

There are a couple of steps that you must do in order to have push notifications working. As they rely on Service Workers, make sure you follow the next steps:

  • Push Notification will need HTTPS everywhere, so be sure your foxbox is running over SSL.
  • Visit https://knilxof.org:4443/ping and add a permanent exception for the certificate.
  • When developing locally (https://localhost:8000) add permanent exception for the self self-signed certificate.

Tips and tricks

  • To start over with a new test, clean the web push database in the foxbox: rm -rf $HOME/.local/share/foxbox/webpush.sqlite and start a Firefox instance with a new profile <path to firefox bin> --profile /tmp/<random>.
  • If you want to perform multiple tries with same profile try to use a service like xip.io. Where you can have different names pointing to your local ip like https://myname.<my local ip>.xip.io:8000 for using this, remember to launch your gulp task like HOST=<my local ip> gulp. Doing this you are creating different origins, which will make you receive multiple notifications (as many as app origin registered).

Tests

All regular tests

Run npm test.

Run end-to-end tests (e2e)

Steps (to be scripted soon):

  1. Clone foxbox
  2. Run it with cargo run
  3. With a browser, perform the first time setup by going to http://localhost:3000
  4. Run gulp test-e2e

Documentation

Generate documentation from the source code with:

$ gulp doc

app's People

Contributors

aosmond avatar arcturus avatar azasypkin avatar ferjm avatar gmarty avatar isabelrios avatar johanlorenzo avatar michielbdejong avatar samgiles avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

app's Issues

Run localhost over HTTPS

Now that we have HTTPS connection end to end we need to run localhost over HTTPS for both the development and testing phases.

The final goal is to disallow all the non secure connections:

  • Redirect the app from HTTP to HTTPS
  • Redirect the registration server similarly
  • Disallow non HTTPS connection to the box

Add auto-reload/watching for unit tests

Currently we use the following snippet during development:

gulp.task('watch-tests', function() {
  gulp.watch([`${TESTS_ROOT}**`], ['build-unit-tests']);
});

gulp.task('debug-unit-tests', function(cb) {
  runSequence(
    'build',
    'watch',
    'watch-tests',
    'run-unit-tests',
    cb
  );
});

We need basically the same, but a bit more polished.

Support iOS Safari

I can see at least two issues so far:

  • let is not supported
  • No fetch API

Should there be a warning when trying to create a recipe that already exists?

In foxbox logs we can see:

[2016-04-22 10:55:45.352] INFO [[email protected]] No need to create a new service for this rule; ID 'Motion Sensor detects motion, light gets turned on.' already exists.

But in the UI there is no warning, you can go ahead with the flow to create a recipe and tap on Done and even taken back to recipes list view as if the recipe was created, but it is not.

What do you think?
Thanks!

GET to <foxbox url>:3000/ping instead of <foxbox url>/ping

Hello @gmarty, there is one issue we would like to check in order to understand if there is a bug:
Scenario:
Running foxbox in pc1 with: cargo run -- -r http://knilxof.org:4242 -t knilxof.org:443 -s foxbox --remote-name test.knilxof.org --disable-tls
Running foxapp in a pc2 firefox browser: https://fxbox.github.io/app
Both in same network.
The list of devices is not retrieved.*

In the network console logs it is possible to see a GET to: test:3000/ping which never gets a 200 response.
Locally running both foxbox and foxapp in same pc is working, could be that fetching the remote url is done correctly but it is failing parsing it?

*Tried foxbox.clear() but then there was this error: Polling has failed, scheduling one more attempt: DOMException[InvalidStateError:"A mutation operation was attempted on a database that did not allow mutations"

Implement smarter polling and ping management

Some ideas:

  • Stop polling service list when we're at Recipe or Service view;
  • When we're at Service view - we can poll only this particular service and maybe with different interval;
  • We can ping the box only when we don't other net activity related to this box (no polling or watch request has been made for some time) or if some of the requests to the box failed for some reason we want to check if it's because of box unavailability.

Cannot open the app from Chrome beta on android

This was working for me before. Now I get the log in page, but it is like it does not detect the foxbox since the Connect to foxbox button never gets active...
Will try with other devices...

Don't transpile to es5

For now we're only targeting recent browsers: the latest Fennec and Chrome for Android.
They all support es6 features, so we can safely disable the es2015 preset of Babel.

In the future, as we add support for more browsers, we can only transpile the feature not natively supported in those.

UI views not correctly resized

Not urgent but maybe to have in mind...
The camera name is cut isntead of showing ellipsis:
captura de pantalla 2016-04-14 a las 11 31 25

New Recipe title seems not to be properly scaled:
captura de pantalla 2016-04-14 a las 11 31 42

Thanks!

Create admin user from app?

Right now, the user must first create an admin password on http://192.168.0.42/, before they connect to http://app.knilxof.org (or wherever we will host the app in this repo). That makes the whole discovery mechanism in this app pretty useless :)

possible solution: send the user straight to app.knilxof.org and do the admin user creation from there, but that's something we should discuss, because:

  • Will we also allow third-party apps to create the admin user?
  • If so, will we whitelist the origins from which this is allowed?

Support multiple box

When the discovery server returns several boxes, the user should be able to select one.

We hit that frequently in the office...

@azasypkin or @gmarty is that something you can look at this week?

Port the deployment script to Gulp

The current deployment script, deploy.sh, is executed until the end even if one of the previous steps fail, potentially leading to an unstable/buggy version of the app online.
If we use a Gulp task, the process will stop at the first error.

Cannot take a picture

With the same version of foxbox and foxapp I was able to take a picture without problems but it stopped working.

I can see in the console: "Error occurred while making a snapshot: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data" when tapping on the button to take a snapshot and the next screen with the view of the picture is not shown.
Although in the foxbox traces I can see that actually the picture was taken:
[2016-04-14 11:11:14.042] INFO Took a snapshot from ae67e622-7a66-465e-bab0-b0c5541a6eb4: /Users/irios/.local/share/foxbox/snapshots/ae67e622-7a66-465e-bab0-b0c5541a6eb4/2016-04-14-111114.jpg_

*One thing I have not done before I saw this issue was trying to add a recipe including the camera, but it was not added as per bug issue #68 and also I closed everything and launched both foxbox and foxapp from the scratch.

Cannot remove and add recipe with the same name

Created a recipe 'Everyday in the evening, Camera take a picture'
Then I removed it with the 'x' button
I tried to create it again but was not able, I click on Done and although I taken back to the recipe list view it is not added and got this error in foxbox:

(this log is since I start creating it for the fist time)
[2016-04-14 17:31:11.098] INFO Thinkerbell: Starting compilation of script 'Everyday in the evening, Camera take a picture.'
[2016-04-14 17:31:11.098] INFO Thinkerbell: Starting execution of script 'Everyday in the evening, Camera take a picture.'
[2016-04-14 17:31:11.100] INFO Added Thinkerbell Rule for 'Everyday in the evening, Camera take a picture.'
[2016-04-14 17:31:20.583] INFO Removed Thinkerbell Rule for 'Everyday in the evening, Camera take a picture.'
[2016-04-14 17:31:38.342] INFO Thinkerbell: Starting compilation of script 'Everyday in the evening, Camera take a picture.'
[2016-04-14 17:31:38.343] INFO Thinkerbell: Starting execution of script 'Everyday in the evening, Camera take a picture.'
[2016-04-14 17:31:38.345] INFO No need to add new ThinkerbellRule; ID 'Everyday in the evening, Camera take a picture.' already exists.

Status of the light bulb is not kept when loging out

Not sure this is also related or caused by issue 77
Once the app is open, from the home view change the status of a light from on to off. (Due to issue 77 you first have to uncheck the check box and then check it again so the light is on)
If you log out and then log in with same user, the light status according to the app is on, but it is actually off.

Optimise React for production builds

Babel react conserves the propTypes of components (which is both expected and wanted).
But in production mode they add no benefits to the components so we want to remove them.

Let's enquire and see if it's a common practice in the React world and if there are already tools to do that.

Make FoxBox discovery (more) secure

Problem:

We are making good progress on FoxBox discovery inside a trusted local network, but if the local network is not trusted, an attacker inside your WiFi network could become a Man-in-the-Middle (MitM) between client and FoxBox, spying on your data, and possibly even replaying the commands sent.

Step 1: Trust on First Use (TOFU)

We assume no attacker is present during the setup phase, but once the app has discovered the FoxBox, comms should become TLS-protected, so that a MitM can only attack during the setup phase, and not at a later point in time.

Step 2: QR-code-base

To make the setup phase secure as well, the user should bring the client physically close to the FoxBox, and then somehow tell the client "this physical object is the one I want to connect to". I'm calling this QR-code-based because that provokes a clear mental image, but you could also use NFC, a USB cable, a PIN code, etc. to achieve the same.

To do:

  • TOFU-based secure discovery
  • See if TOFU can be done at the OS level instead of at the application level
    • on Android
    • on Windows 10
    • etc ...
  • QR-code-based
    • Work out the https://<fingerprint>.foxbox<i>.<special-tld> idea in more detail
    • Server-side implementation (just set the hostname based on the signing cert's fingerprint)
    • Remove reliance on [m]DNS - i.e. allow using an IP address instead of a domain name
    • Implementation in Cordova
    • Implementation in WebExtension
  • Coordinate this work with FlyWeb - they have the exact same problem

Remove all usages of return value for `ReactDOM.render` and `TestUtils.renderIntoDocument`

As per [1] we shouldn't rely on return value of ReactDOM.render and TestUtils.renderIntoDocument because of:

ReactDOM.render() currently returns a reference to the root ReactComponent instance.
However, using this return value is legacy and should be avoided because future versions
of React may render components asynchronously in some cases. If you need a reference
to the root ReactComponent instance, the preferred solution is to attach a callback ref to
the root element.

It's also a reason of some unit tests intermittent failures we have currently.

[1] https://facebook.github.io/react/docs/top-level-api.html

Make Cordova the default build

Some Foxboxes don't use any hosted services. In the current box-client discovery proposal, this will be the default build for Foxbox.

Some other Foxboxes will use Mozilla-hosted services, and others still will use self-hosted services (hosted by the end-user or their friend, or by a hardware-vendor, OEM, etc.).

To discover and interact with all these Foxboxes, this app has to support not only the DNS-server+registration_server+LetsEncrypt discovery flow, but also the mDNS + TOFU discovery flow.

There are two ways to build this app: as a Cordova app, or as a statically-hosted (client-side) web app.

We obviously love using web apps rather than Cordova apps whenever possible, but in this case that comes at the price of functionality: only the Cordova build of this app will be able to support mDNS + TOFU discovery.

That's why I propose to make the Cordova build the default way to build this app, and make "deploy to gh-pages" only an option, adding a warning that "not all Foxboxes will be supported".

I wanted to get some feedback to see if anyone sees any alternative paths of action here, before moving forward with updating the readme with this change. Will also post a link to this issue to the mailing list.

Not possible to differentiate which light is actually being used and the correct status

Here an screenshot of what I have
captura de pantalla 2016-04-13 a las 15 26 15

@gmarty A few things related to the status of the light services:
I am using only light bulb 2, the other two are not connected, I would expect the other light services to be greyed out or shown in a different way?
Also the checkbox for all of them appears as clicked which is the status for on, and they are off.
And, about the red square, should it change to green when turning on the light?

I added several comments here, since not sure they are actually issues, if they are, I can open separate issues if you prefer. Thanks!

Home view should always keep services ordered by name and grouped by type

Currently if we have let's say Service 1, Service 2 and Service 3. They are saved in Indexed DB, when user opens the app we display services in particular order, but once we receive service list from the box the order of these services can change sometimes even if we still have the same services.

IIRC @fabricedesre was the one who was particularly complaining about this weird behavior :)

[Experiment] Implement Watchers

We don't have websockets/event source yet, but we need to display changes in state (door lock closed manually, user switched lights off and etc) - UI should be updated accordingly. The only way for now is to do polling - with the Taxonomy we can do very efficient polling.

So in the scope of this bug I want to try idea with Watchers that could accept any number of getter and poll all of them at once.

Likely this experiment will rely on #107

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.