IoT Smart Planter PWA Client
nodejs
and npm
are required to run webpack to build the JavaScript client in
this project. If you do not have node
/ npm
installed you can install it
with the following script.
curl -L https://gist.github.com/pdxjohnny/75dee455b7ddb7334b88/raw/9828b128a6d927e9457cd0d92c8b51660a79ffbe/node-user.sh | bash && source ${HOME}/.bashrc
cd ~/public_html/
git clone [email protected]:pdxjohnny/smartplanter smartplanterdev
cd smartplanterdev
./scripts/setup.sh
The smartplanter app is now accessible at
echo https://web.cecs.pdx.edu/~$USER/smartplanter/dist/
These are currently committed to the repo. To re-generate run the create-vapid script.
Keys are only committed to the repo now because storage of them in a secure way would be complex to manage. Under no circumstances should they become publicly available. If this application is to become production ready they must be stored in a secure location and deployment should account for their retrieval at time of application stand up.
./scripts/create-vapid
Generated with RealFaviconGenerator
Put this htaccess file in your public_html folder.
cat > ~/public_html/.htaccess <<'EOF'
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
EOF
Endpoint returns a JSON with user ID and a JWT which should be used in the Authorization header.
curl 'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/createuser/?password=test'
# export TOKEN=`result of token in the above JSON reponse`
curl 'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/login/?id=42&password=test'
# export TOKEN=`result of token in the above JSON reponse`
curl -H "Authorization: Bearer $TOKEN" \
-d 'Hello World'
'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/sync/'
curl -X PUT \
-H "Authorization: Bearer $TOKEN" \
-d 'Hello World'
'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/sync/?resource=<created ID>'
curl -H "Authorization: Bearer $TOKEN" \
'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/sync/?resource=<created ID>'
You should see Hello World
curl -H "Authorization: Bearer $TOKEN" \
'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/createplanter/'
# export PTOKEN=`result of token in the above JSON reponse`
curl -X PUT \
-H "Authorization: Bearer $PTOKEN" \
-d 'Hello World'
'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/sync/'
curl -H "Authorization: Bearer $PTOKEN" \
'https://web.cecs.pdx.edu/~jsa3/smartplanter/api/sync/'
- Push notifications (WebPush incompatibility with php 7.0 only compatible with 7.1 and above, fork and fix)
- Offline compatibility (All libs use fetch and the mixed content hack doesn't work with that)
- UX Improvements, notification of planter received changes
- Increase bcrypt cost to something secure