From 3baf79e8f64d1f0597931f93e00e590a80fa5b89 Mon Sep 17 00:00:00 2001
From: Georg Reisinger <43533139+GeorgReisinger@users.noreply.github.com>
Date: Sun, 24 Feb 2019 19:27:42 +0100
Subject: [PATCH] Email Login
---
express-server/app.js | 10 +-
express-server/db-config/keys.js | 16 +-
express-server/db-config/postgresql-common.js | 45 +-
express-server/db-connect/db-connect.js | 225 +-
express-server/greenlock-https/demo.js | 49 +-
express-server/greenlock-https/force-renew.js | 37 +-
express-server/greenlock-https/http2.js | 44 +-
.../greenlock-https/my-express-app.js | 6 +-
express-server/greenlock-https/production.js | 48 +-
express-server/greenlock-https/quickstart.js | 43 +-
.../greenlock-https/remote-access.js | 84 +-
express-server/greenlock-https/spdy.js | 45 +-
express-server/greenlock-https/vhost.js | 48 +-
express-server/greenlock-https/websockets.js | 40 +-
express-server/greenlock.js | 40 +-
express-server/https.js | 40 +-
express-server/login/firebaseAdminKey.json | 2 +-
.../public/firebase-messaging-sw.js | 4 +-
express-server/public/invite/inv.js | 157 +-
express-server/public/invite/style.css | 2 +-
express-server/public/javascripts/ajax.js | 438 ++-
express-server/public/javascripts/axios.js | 3268 +++++++++--------
.../public/javascripts/firebase-app.js | 79 +-
express-server/public/javascripts/login.js | 173 +-
express-server/public/javascripts/test.js | 32 +-
express-server/public/ocrscan/cam.js | 10 +-
express-server/public/ocrscan/dropzone.js | 86 +-
express-server/public/ocrscan/ocrscan.js | 388 +-
express-server/push/push.js | 7 +-
express-server/routes/index.js | 253 +-
express-server/routes/users.js | 4 +-
express-server/test/greenlock.js | 16 +-
express-server/views/androidlogin.ejs | 36 -
express-server/views/dash.ejs | 242 +-
express-server/views/error.ejs | 10 +-
express-server/views/index.ejs | 33 +-
express-server/views/invite.ejs | 11 +-
express-server/views/invitelogin.ejs | 2 +-
express-server/views/ocrscan.ejs | 155 +-
39 files changed, 3246 insertions(+), 2982 deletions(-)
delete mode 100644 express-server/views/androidlogin.ejs
diff --git a/express-server/app.js b/express-server/app.js
index 0c2de42a..d57cdfb2 100644
--- a/express-server/app.js
+++ b/express-server/app.js
@@ -15,7 +15,9 @@ app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(express.json());
-app.use(express.urlencoded({ extended: false }));
+app.use(express.urlencoded({
+ extended: false
+}));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', indexRouter);
@@ -23,14 +25,14 @@ app.use(axios);
app.use('/users', usersRouter);
// catch 404 and forward to error handler
-app.use(function(req, res, next) {
+app.use(function (req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handler
-app.use(function(err, req, res, next) {
+app.use(function (err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
@@ -40,4 +42,4 @@ app.use(function(err, req, res, next) {
res.render('error');
});
-module.exports = app;
+module.exports = app;
\ No newline at end of file
diff --git a/express-server/db-config/keys.js b/express-server/db-config/keys.js
index bd3db0a2..7c9692b7 100644
--- a/express-server/db-config/keys.js
+++ b/express-server/db-config/keys.js
@@ -1,9 +1,9 @@
-module.exports ={
- postgresSQL:{
- user:"smartshopper-user",
- host:"188.166.124.80",
- database:"smartshopperdb",
- password:"jW^v#&LjNY_b3-k*jYj!U4Xz?T??m_D6249XAeWZ#7C^FRbKm!c_Dt+qj@4&a-Hs",
- port:"5432"
+module.exports = {
+ postgresSQL: {
+ user: "smartshopper-user",
+ host: "188.166.124.80",
+ database: "smartshopperdb",
+ password: "jW^v#&LjNY_b3-k*jYj!U4Xz?T??m_D6249XAeWZ#7C^FRbKm!c_Dt+qj@4&a-Hs",
+ port: "5432"
}
-}
+}
\ No newline at end of file
diff --git a/express-server/db-config/postgresql-common.js b/express-server/db-config/postgresql-common.js
index 8717cc67..d0314972 100644
--- a/express-server/db-config/postgresql-common.js
+++ b/express-server/db-config/postgresql-common.js
@@ -1,45 +1,44 @@
-const { Client } = require ("pg");
-const {postgresSQL} = require("./keys")
+const {
+ Client
+} = require("pg");
+const {
+ postgresSQL
+} = require("./keys")
const client = new Client(postgresSQL);
async function connect() {
- try{
- await client.connect();
- console.log("Database connected!");
- }
- catch(error)
- {
+ try {
+ await client.connect();
+ console.log("Database connected!");
+ } catch (error) {
console.error(error)
}
}
connect();
-async function query(queryString,param)
-{
+async function query(queryString, param) {
try {
- let result = await client.query(queryString,param);
- let resultarray = [];
- for(let row of result.rows)
- {
- resultarray.push(row.obj);
- }
- return resultarray;
- }
- catch(error)
- {
+ let result = await client.query(queryString, param);
+ let resultarray = [];
+ for (let row of result.rows) {
+ resultarray.push(row.obj);
+ }
+ return resultarray;
+ } catch (error) {
console.log(error)
}
}
-async function nonQuery(queryString,param) {
+async function nonQuery(queryString, param) {
try {
- await client.query(queryString,param);
+ await client.query(queryString, param);
} catch (error) {
console.error(error)
}
}
module.exports = {
- query, nonQuery
+ query,
+ nonQuery
}
\ No newline at end of file
diff --git a/express-server/db-connect/db-connect.js b/express-server/db-connect/db-connect.js
index 0f1cdebd..2adfa362 100644
--- a/express-server/db-connect/db-connect.js
+++ b/express-server/db-connect/db-connect.js
@@ -1,4 +1,7 @@
-const { query, nonQuery } = require("../db-config/postgresql-common");
+const {
+ query,
+ nonQuery
+} = require("../db-config/postgresql-common");
const stringSimilarity = require('string-similarity');
@@ -7,12 +10,10 @@ const stringSimilarity = require('string-similarity');
//Create User Info
async function updateUser(uid, mid, name, picture, email) {
- try {
+ try {
await nonQuery('INSERT INTO "User" (username, message_id, name, picture, email) VALUES ($1, $2, $3, $4, $5);', [uid, mid, name, picture, email]);
-
- }
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -22,10 +23,8 @@ async function getmessageids(sl_id) {
let members = query('SELECT * FROM "Shoppinglist_member" WHERE sl_id = $1;', [sl_id]);
let admin = query('SELECT * FROM "Shoppinglist_admin" WHERE sl_id = $1;', [sl_id]);
return users_to_array(admin, members);
-
- }
- catch(error) {
+ } catch (error) {
}
}
@@ -35,13 +34,13 @@ async function getmessageids(sl_id) {
async function searchUsers(searchstring) {
try {
let users = await query('SELECT row_to_json("User") AS obj FROM "User";');
- return users.filter(function(obj) {return obj.name.toUpperCase().includes(searchstring.toUpperCase())});
- }
-
- catch(error) {
+ return users.filter(function (obj) {
+ return obj.name.toUpperCase().includes(searchstring.toUpperCase())
+ });
+ } catch (error) {
console.error(error);
}
-
+
}
@@ -49,14 +48,12 @@ async function searchUsers(searchstring) {
//SELECT own shopping lists
async function getShoppinglistsAdmin(username) {
try {
-
+
let result = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" JOIN "Shoppinglist_admin" USING (sl_id) WHERE \
username = $1', [username]);
return result;
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -67,9 +64,7 @@ async function getShoppinglistsByLink(link) {
console.log("PPPPP LIIINK:", link)
let result = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" WHERE invitelink = $1', [link]);
return result;
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -81,9 +76,7 @@ async function getShoppinglistsShared(username) {
let result = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" JOIN "Shoppinglist_member" USING (sl_id) WHERE username = $1;', [username]);
console.log(result);
return result;
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -100,27 +93,21 @@ async function newShoppinglist(name, description, username, color) {
try {
await nonQuery('INSERT INTO "User" (username) VALUES ($1);', [username]);
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
//insert shoppinglist
try {
await nonQuery('INSERT INTO "Shoppinglist" (sl_id, name, description, color) VALUES ($1, $2, $3, $4);', [sl_id, name, description, color]);
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
//insert admin
try {
await nonQuery('INSERT INTO "Shoppinglist_admin" (username, sl_id) VALUES ($1, $2);', [username, sl_id]);
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -131,21 +118,19 @@ async function newShoppinglist(name, description, username, color) {
async function editShoppinglist(sl_id, newname, newdescription, newcolor) {
try {
let shoppinglist = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" WHERE sl_id = $1;', [sl_id]);
-
- if(shoppinglist.name != newname && newname != undefined) {
+
+ if (shoppinglist.name != newname && newname != undefined) {
await nonQuery('UPDATE "Shoppinglist" SET name = $1 WHERE sl_id = $2;', [newname, sl_id]);
}
- if(shoppinglist.description != newdescription && newdescription != undefined) {
+ if (shoppinglist.description != newdescription && newdescription != undefined) {
await nonQuery('UPDATE "Shoppinglist" SET description = $1 WHERE sl_id = $2;', [newdescription, sl_id]);
}
- if(shoppinglist.color != newcolor && newcolor != undefined) {
+ if (shoppinglist.color != newcolor && newcolor != undefined) {
await nonQuery('UPDATE "Shoppinglist" SET color = $1 WHERE sl_id = $2;', [newcolor, sl_id]);
}
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -173,9 +158,7 @@ async function displayShoppinglist(sl_id) {
let admin = await query('SELECT row_to_json("User") as obj FROM "User" JOIN "Shoppinglist_admin" USING (username) WHERE sl_id = $1', [sl_id]);
return items_in_groups(groups, items, sl_id, admin[0].username, admin[0].message_id, members, shoppinglist[0].name, shoppinglist[0].description);
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -188,9 +171,7 @@ async function deleteShoppinglist(sl_id) {
await nonQuery('DELETE FROM "Shoppinglist_admin" WHERE sl_id = $1', [sl_id]);
await nonQuery('DELETE FROM "Shoppinglist_member" WHERE sl_id = $1', [sl_id]);
await nonQuery('DELETE FROM "Shoppinglist" WHERE sl_id = $1', [sl_id]);
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -201,9 +182,7 @@ async function addGroup(sl_id, name, color, hidden) {
try {
let grid = generate_group_id();
await nonQuery('INSERT INTO "Group" (group_id, sl_id, name, color, hidden) VALUES ($1, $2, $3, $4, $5);', [grid, sl_id, name, color, hidden]);
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -214,9 +193,7 @@ async function addItem(group_id, sl_id, name, count) {
try {
let itid = generate_item_id();
await nonQuery('INSERT INTO "Item" VALUES ($1, $2, $3, $4, $5);', [itid, group_id, sl_id, name, count]);
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -224,23 +201,21 @@ async function addItem(group_id, sl_id, name, count) {
//Edit Group
async function editGroup(sl_id, group_id, name, color, hidden) {
try {
- let group = await query('SELECT row_to_json("Group") AS obj FROM "Group" WHERE group_id = $1 AND sl_id = $2', [sl_id, group_id]);
+ let group = await query('SELECT row_to_json("Group") AS obj FROM "Group" WHERE group_id = $1 AND sl_id = $2', [sl_id, group_id]);
- if(group.name != name && name != undefined) {
+ if (group.name != name && name != undefined) {
await nonQuery('UPDATE "Group" SET name = $1 WHERE group_id = $2 AND sl_id = $3;', [name, group_id, sl_id]);
}
- if(group.color != color && color != undefined) {
+ if (group.color != color && color != undefined) {
await nonQuery('UPDATE "Group" SET color = $1 WHERE group_id = $2 AND sl_id = $3;', [color, group_id, sl_id]);
}
- if(group.hidden != hidden && hidden != undefined) {
+ if (group.hidden != hidden && hidden != undefined) {
await nonQuery('UPDATE "Group" SET hidden = $1 WHERE group_id = $2 AND sl_id = $3;', [hidden, group_id, sl_id]);
}
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -252,16 +227,14 @@ async function editItem(sl_id, group_id, item_id, name, count) {
try {
let item = query('SELECT row_to_json("Item") FROM "Item" WHERE item_id = $1 AND group_id = $2 AND sl_id = $3', [item_id, group_id, sl_id]);
- if(item.name != name && name != undefined) {
+ if (item.name != name && name != undefined) {
await nonQuery('UPDATE "Item" SET name = $1 WHERE item_id = $2 AND group_id = $3 AND sl_id = $4', [name, item_id, group_id, sl_id]);
}
- if(item.count != count && count != undefined) {
+ if (item.count != count && count != undefined) {
await nonQuery('UPDATE "Item" SET count = $1 WHERE item_id = $2 AND group_id = $3 AND sl_id = $4', [count, item_id, group_id, sl_id]);
}
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -275,9 +248,7 @@ async function deleteGroup(group_id, sl_id) {
//Leere Gruppe löschen
nonQuery('DELETE FROM "Group" WHERE group_id = $1 AND sl_id = $2', [group_id, sl_id]);
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -287,9 +258,7 @@ async function deleteGroup(group_id, sl_id) {
async function deleteItem(item_id, group_id, sl_id) {
try {
nonQuery('DELETE FROM "Item" WHERE item_id = $1 AND group_id = $2 AND sl_id = $3;', [item_id, group_id, sl_id]);
- }
-
- catch(error) {
+ } catch (error) {
console.error(error);
}
}
@@ -304,35 +273,33 @@ async function moveDoneItems(uid, sl_id, billcontent) {
var today = new Date();
var dd = today.getDate();
- var mm = today.getMonth()+1;
+ var mm = today.getMonth() + 1;
var yyyy = today.getFullYear();
- if(dd<10) {
- dd = '0'+dd
- }
+ if (dd < 10) {
+ dd = '0' + dd
+ }
- if(mm<10) {
- mm = '0'+mm
- }
+ if (mm < 10) {
+ mm = '0' + mm
+ }
today = mm + '/' + dd + '/' + yyyy;
- for(let item of removeableItems) {
+ for (let item of removeableItems) {
await nonQuery('INSERT INTO "Done_Purchase" (purchased_item_id, username, name, date, count) VALUES($1,$2,$3,$4,$5);',
- [generate_item_id(), uid, item.name, today, 1]);
+ [generate_item_id(), uid, item.name, today, 1]);
}
-
- for(let item of removeableItems) {
+
+ for (let item of removeableItems) {
await nonQuery('DELETE FROM "Item" WHERE item_id = $1 AND group_id = $2 AND sl_id = $3;', [item.item_id, item.group_id, item.sl_id]);
console.log(item);
}
return "done"
- }
-
- catch(error) {
+ } catch (error) {
console.error(error);
}
}
@@ -343,9 +310,7 @@ async function getDonePurchases(uid) {
try {
let result = await query('SELECT row_to_json("Done_Purchase") AS obj FROM "Done_Purchase" WHERE username = $1;', [uid]);
return result;
- }
-
- catch(error) {
+ } catch (error) {
console.error(error);
}
}
@@ -366,9 +331,7 @@ async function verifyInvite(link, user_id) {
let sl_id = result[0].sl_id;
console.log("!!! SL ID: ", sl_id);
await nonQuery('INSERT INTO "Shoppinglist_member" (username, sl_id) VALUES ($1, $2);', [user_id, sl_id]);
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -377,9 +340,7 @@ async function createInvite(sl_id) {
try {
let link = generateInviteLink();
await nonQuery('UPDATE "Shoppinglist" SET invitelink = $1 WHERE sl_id = $2;', [link, sl_id]);
- }
-
- catch (error) {
+ } catch (error) {
console.error(error);
}
}
@@ -388,9 +349,7 @@ async function createInvite(sl_id) {
async function manInvite(sl_id, uid) {
try {
await nonQuery('INSERT INTO "Shoppinglist_member" (username, sl_id) VALUES ($1, $2);', [uid, sl_id]);
- }
-
- catch(error) {
+ } catch (error) {
console.error(error);
}
}
@@ -400,9 +359,7 @@ async function manInvite(sl_id, uid) {
async function removeMember(uid, sl_id) {
try {
await nonQuery('DELETE FROM "Shoppinglist_member" WHERE username = $1 AND sl_id = $2', [uid, sl_id]);
- }
-
- catch(error) {
+ } catch (error) {
console.error(error);
}
}
@@ -417,7 +374,7 @@ function generate_sl_id() {
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var output = "";
- for(let i = 0; i < 8; i++) {
+ for (let i = 0; i < 8; i++) {
output += possible.charAt(Math.floor(Math.random() * possible.length));
}
@@ -429,7 +386,7 @@ function generate_group_id() {
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var output = "";
- for(let i = 0; i < 8; i++) {
+ for (let i = 0; i < 8; i++) {
output += possible.charAt(Math.floor(Math.random() * possible.length));
}
@@ -441,7 +398,7 @@ function generate_item_id() {
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var output = "";
- for(let i = 0; i < 8; i++) {
+ for (let i = 0; i < 8; i++) {
output += possible.charAt(Math.floor(Math.random() * possible.length));
}
@@ -462,17 +419,19 @@ function items_in_groups(groups, items, sl_id, admin_uid, admin_mid, members, na
groups: []
};
- for(let item of groups) {
+ for (let item of groups) {
result.groups.push({
group_id: item.group_id,
name: item.name,
color: item.color,
- content: items.filter(function(obj) {return obj.group_id == item.group_id})
+ content: items.filter(function (obj) {
+ return obj.group_id == item.group_id
+ })
});
}
- for(let item of members) {
+ for (let item of members) {
result.members.push({
uid: item.username,
@@ -488,7 +447,7 @@ function generateInviteLink() {
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var output = "";
- for(let i = 0; i < 50; i++) {
+ for (let i = 0; i < 50; i++) {
output += possible.charAt(Math.floor(Math.random() * possible.length));
}
@@ -500,7 +459,7 @@ function users_to_array(admin, members) {
users.push(admin.username);
- for(let item of members) {
+ for (let item of members) {
users.push(item.username);
}
@@ -513,28 +472,18 @@ function compareData(listitems, doneitems) {
let output = [];
- for(let item of listitems) {
- if(doneitems.includes(item.name)) {
+ for (let item of listitems) {
+ if (doneitems.includes(item.name)) {
output.push(item);
- }
-
- else if(doneitems.toUpperCase().includes(item.name.toUpperCase())) {
+ } else if (doneitems.toUpperCase().includes(item.name.toUpperCase())) {
output.push(item);
- }
-
- else if(doneitems.toLowerCase().includes(item.name.toLowerCase())) {
+ } else if (doneitems.toLowerCase().includes(item.name.toLowerCase())) {
output.push(item);
- }
-
- else if(probability(item.name, doneitems) > 0.6) {
+ } else if (probability(item.name, doneitems) > 0.6) {
output.push(item);
- }
-
- else if(probability(item.name.toUpperCase(), doneitems.toUpperCase()) > 0.6) {
+ } else if (probability(item.name.toUpperCase(), doneitems.toUpperCase()) > 0.6) {
output.push(item);
- }
-
- else if(probability(item.name.toLowerCase(), doneitems.toLowerCase()) > 0.6) {
+ } else if (probability(item.name.toLowerCase(), doneitems.toLowerCase()) > 0.6) {
output.push(item);
}
}
@@ -546,11 +495,11 @@ function probability(cur_item, data) {
let best = 0;
- for(let i = 0; i < data.length; i++) {
+ for (let i = 0; i < data.length; i++) {
let prob = stringSimilarity.compareTwoStrings(cur_item, data.slice(i, i + cur_item.length));
- if(prob > best) {
+ if (prob > best) {
best = prob;
}
}
@@ -561,7 +510,25 @@ function probability(cur_item, data) {
module.exports = {
- getShoppinglistsAdmin, getShoppinglistsShared, newShoppinglist, displayShoppinglist, deleteShoppinglist, addGroup,
- addItem, verifyInvite, createInvite, editShoppinglist, editGroup, editItem, deleteGroup, deleteItem, manInvite, updateUser,
- moveDoneItems, getDonePurchases, getShoppinglistsByLink, searchUsers, removeMember
-}
+ getShoppinglistsAdmin,
+ getShoppinglistsShared,
+ newShoppinglist,
+ displayShoppinglist,
+ deleteShoppinglist,
+ addGroup,
+ addItem,
+ verifyInvite,
+ createInvite,
+ editShoppinglist,
+ editGroup,
+ editItem,
+ deleteGroup,
+ deleteItem,
+ manInvite,
+ updateUser,
+ moveDoneItems,
+ getDonePurchases,
+ getShoppinglistsByLink,
+ searchUsers,
+ removeMember
+}
\ No newline at end of file
diff --git a/express-server/greenlock-https/demo.js b/express-server/greenlock-https/demo.js
index d9bee690..3572aa35 100644
--- a/express-server/greenlock-https/demo.js
+++ b/express-server/greenlock-https/demo.js
@@ -10,28 +10,34 @@ var greenlock = Greenlock.create({
// Let's Encrypt v2 is ACME draft 11
version: 'draft-11'
-, server: 'https://acme-v02.api.letsencrypt.org/directory'
- // Note: If at first you don't succeed, stop and switch to staging
- // https://acme-staging-v02.api.letsencrypt.org/directory
+ ,
+ server: 'https://acme-v02.api.letsencrypt.org/directory'
+ // Note: If at first you don't succeed, stop and switch to staging
+ // https://acme-staging-v02.api.letsencrypt.org/directory
- // You MUST change this to a valid email address
-, email: 'jon@example.com'
+ // You MUST change this to a valid email address
+ ,
+ email: 'jon@example.com'
- // You MUST NOT build clients that accept the ToS without asking the user
-, agreeTos: true
+ // You MUST NOT build clients that accept the ToS without asking the user
+ ,
+ agreeTos: true
- // You MUST change these to valid domains
- // NOTE: all domains will validated and listed on the certificate
-, approvedDomains: [ 'example.com', 'www.example.com' ]
+ // You MUST change these to valid domains
+ // NOTE: all domains will validated and listed on the certificate
+ ,
+ approvedDomains: ['example.com', 'www.example.com']
- // You MUST have access to write to directory where certs are saved
- // ex: /home/foouser/acme/etc
-, configDir: '~/.config/acme/'
+ // You MUST have access to write to directory where certs are saved
+ // ex: /home/foouser/acme/etc
+ ,
+ configDir: '~/.config/acme/'
- // Get notified of important updates and help me make greenlock better
-, communityMember: true
+ // Get notified of important updates and help me make greenlock better
+ ,
+ communityMember: true
-//, debug: true
+ //, debug: true
});
@@ -45,8 +51,8 @@ var greenlock = Greenlock.create({
var redirectHttps = require('redirect-https')();
var acmeChallengeHandler = greenlock.middleware(function (req, res) {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
- res.end('
Hello, ⚠️ Insecure World!
Visit Secure Site'
- + ''
+ res.end('Hello, ⚠️ Insecure World!
Visit Secure Site' +
+ ''
);
});
require('http').createServer(acmeChallengeHandler).listen(80, function () {
@@ -61,7 +67,10 @@ require('http').createServer(acmeChallengeHandler).listen(80, function () {
// spdy is a drop-in replacement for the https API
var spdyOptions = Object.assign({}, greenlock.tlsOptions);
-spdyOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false };
+spdyOptions.spdy = {
+ protocols: ['h2', 'http/1.1'],
+ plain: false
+};
var server = require('spdy').createServer(spdyOptions, require('express')().use('/', function (req, res) {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.end('Hello, 🔐 Secure World!
');
@@ -72,4 +81,4 @@ server.on('error', function (err) {
server.on('listening', function () {
console.log("Listening for SPDY/http2/https requests on", this.address());
});
-server.listen(443);
+server.listen(443);
\ No newline at end of file
diff --git a/express-server/greenlock-https/force-renew.js b/express-server/greenlock-https/force-renew.js
index 8c8f4638..9bd66a45 100644
--- a/express-server/greenlock-https/force-renew.js
+++ b/express-server/greenlock-https/force-renew.js
@@ -6,24 +6,31 @@ require('../').create({
// Let's Encrypt v2 is ACME draft 11
version: 'draft-11'
-, server: 'https://acme-v02.api.letsencrypt.org/directory'
- // Note: If at first you don't succeed, stop and switch to staging
- // https://acme-staging-v02.api.letsencrypt.org/directory
+ ,
+ server: 'https://acme-v02.api.letsencrypt.org/directory'
+ // Note: If at first you don't succeed, stop and switch to staging
+ // https://acme-staging-v02.api.letsencrypt.org/directory
-, email: 'john.doe@example.com'
+ ,
+ email: 'john.doe@example.com'
-, agreeTos: true
+ ,
+ agreeTos: true
-, approvedDomains: [ 'example.com', 'www.example.com' ]
+ ,
+ approvedDomains: ['example.com', 'www.example.com']
-, app: require('express')().use('/', function (req, res) {
- res.end('Hello, World!');
- })
+ ,
+ app: require('express')().use('/', function (req, res) {
+ res.end('Hello, World!');
+ })
-, renewWithin: (91 * 24 * 60 * 60 * 1000)
-, renewBy: (90 * 24 * 60 * 60 * 1000)
+ ,
+ renewWithin: (91 * 24 * 60 * 60 * 1000),
+ renewBy: (90 * 24 * 60 * 60 * 1000)
- // Get notified of important updates and help me make greenlock better
-, communityMember: true
-, debug: true
-}).listen(80, 443);
+ // Get notified of important updates and help me make greenlock better
+ ,
+ communityMember: true,
+ debug: true
+}).listen(80, 443);
\ No newline at end of file
diff --git a/express-server/greenlock-https/http2.js b/express-server/greenlock-https/http2.js
index 5b30c65e..a0d197f0 100644
--- a/express-server/greenlock-https/http2.js
+++ b/express-server/greenlock-https/http2.js
@@ -8,28 +8,34 @@ var greenlock = Greenlock.create({
// Let's Encrypt v2 is ACME draft 11
version: 'draft-11'
-, server: 'https://acme-v02.api.letsencrypt.org/directory'
- // Note: If at first you don't succeed, stop and switch to staging
- // https://acme-staging-v02.api.letsencrypt.org/directory
+ ,
+ server: 'https://acme-v02.api.letsencrypt.org/directory'
+ // Note: If at first you don't succeed, stop and switch to staging
+ // https://acme-staging-v02.api.letsencrypt.org/directory
- // You MUST change this to a valid email address
-, email: 'jon@example.com'
+ // You MUST change this to a valid email address
+ ,
+ email: 'jon@example.com'
- // You MUST NOT build clients that accept the ToS without asking the user
-, agreeTos: true
+ // You MUST NOT build clients that accept the ToS without asking the user
+ ,
+ agreeTos: true
- // You MUST change these to valid domains
- // NOTE: all domains will validated and listed on the certificate
-, approvedDomains: [ 'example.com', 'www.example.com' ]
+ // You MUST change these to valid domains
+ // NOTE: all domains will validated and listed on the certificate
+ ,
+ approvedDomains: ['example.com', 'www.example.com']
- // You MUST have access to write to directory where certs are saved
- // ex: /home/foouser/acme/etc
-, configDir: '~/.config/acme/'
+ // You MUST have access to write to directory where certs are saved
+ // ex: /home/foouser/acme/etc
+ ,
+ configDir: '~/.config/acme/'
- // Get notified of important updates and help me make greenlock better
-, communityMember: true
+ // Get notified of important updates and help me make greenlock better
+ ,
+ communityMember: true
-//, debug: true
+ //, debug: true
});
@@ -63,12 +69,12 @@ server.on('error', function (err) {
server.on('stream', function (stream, headers) {
console.log(headers);
stream.respond({
- 'content-type': 'text/html'
- , ':status': 200
+ 'content-type': 'text/html',
+ ':status': 200
});
stream.end('Hello, HTTP2 World!');
});
server.on('listening', function () {
console.log("Listening for http2 requests on", this.address());
});
-server.listen(443);
+server.listen(443);
\ No newline at end of file
diff --git a/express-server/greenlock-https/my-express-app.js b/express-server/greenlock-https/my-express-app.js
index 04da0987..ea3b5e84 100644
--- a/express-server/greenlock-https/my-express-app.js
+++ b/express-server/greenlock-https/my-express-app.js
@@ -9,7 +9,9 @@ app.use('/', function (req, res) {
});
// DO NOT DO app.listen() unless we're testing this directly
-if (require.main === module) { app.listen(3000); }
+if (require.main === module) {
+ app.listen(3000);
+}
// Instead do export the app:
-module.exports = app;
+module.exports = app;
\ No newline at end of file
diff --git a/express-server/greenlock-https/production.js b/express-server/greenlock-https/production.js
index 08ee7efc..bb1f232f 100644
--- a/express-server/greenlock-https/production.js
+++ b/express-server/greenlock-https/production.js
@@ -9,26 +9,30 @@ var greenlock = require('../').create({
// Let's Encrypt v2 is ACME draft 11
// Note: If at first you don't succeed, stop and switch to staging
// https://acme-staging-v02.api.letsencrypt.org/directory
- server: 'https://acme-v02.api.letsencrypt.org/directory'
-, version: 'draft-11'
- // You MUST have write access to save certs
-, configDir: '~/.config/acme/'
+ server: 'https://acme-v02.api.letsencrypt.org/directory',
+ version: 'draft-11'
+ // You MUST have write access to save certs
+ ,
+ configDir: '~/.config/acme/'
-// The previous 'simple' example set these values statically,
-// but this example uses approveDomains() to set them dynamically
-//, email: 'none@see.note.above'
-//, agreeTos: false
+ // The previous 'simple' example set these values statically,
+ // but this example uses approveDomains() to set them dynamically
+ //, email: 'none@see.note.above'
+ //, agreeTos: false
- // approveDomains is the right place to check a database for
- // email addresses with domains and agreements and such
-, approveDomains: approveDomains
+ // approveDomains is the right place to check a database for
+ // email addresses with domains and agreements and such
+ ,
+ approveDomains: approveDomains
-, app: require('./my-express-app.js')
+ ,
+ app: require('./my-express-app.js')
- // Get notified of important updates and help me make greenlock better
-, communityMember: true
+ // Get notified of important updates and help me make greenlock better
+ ,
+ communityMember: true
-//, debug: true
+ //, debug: true
});
@@ -52,7 +56,10 @@ function approveDomains(opts, certs, cb) {
}
fooCheckDb(opts.domains, function (err, agree, email) {
- if (err) { cb(err); return; }
+ if (err) {
+ cb(err);
+ return;
+ }
// Services SHOULD automatically accept the ToS and use YOUR email
// Clients MUST NOT accept the ToS without asking the user
@@ -64,7 +71,10 @@ function approveDomains(opts, certs, cb) {
// opts.challengeType = 'http-01';
// opts.challenge = require('le-challenge-fs').create({});
- cb(null, { options: opts, certs: certs });
+ cb(null, {
+ options: opts,
+ certs: certs
+ });
});
}
@@ -75,7 +85,7 @@ function approveDomains(opts, certs, cb) {
function fooCheckDb(domains, cb) {
// This is an oversimplified example of how we might implement a check in
// our database if we have different rules for different users and domains
- var domains = [ 'example.com', 'www.example.com' ];
+ var domains = ['example.com', 'www.example.com'];
var userEmail = 'john.doe@example.com';
var userAgrees = true;
var passCheck = opts.domains.every(function (domain) {
@@ -87,4 +97,4 @@ function fooCheckDb(domains, cb) {
} else {
cb(null, userAgrees, userEmail);
}
-}
+}
\ No newline at end of file
diff --git a/express-server/greenlock-https/quickstart.js b/express-server/greenlock-https/quickstart.js
index 41cca182..3eb2d372 100644
--- a/express-server/greenlock-https/quickstart.js
+++ b/express-server/greenlock-https/quickstart.js
@@ -8,29 +8,36 @@ require('../greenlock.js').create({
// Let's Encrypt v2 is ACME draft 11
version: 'draft-11'
-, server: 'https://acme-v02.api.letsencrypt.org/directory'
- // Note: If at first you don't succeed, stop and switch to staging
- // https://acme-staging-v02.api.letsencrypt.org/directory
+ ,
+ server: 'https://acme-v02.api.letsencrypt.org/directory'
+ // Note: If at first you don't succeed, stop and switch to staging
+ // https://acme-staging-v02.api.letsencrypt.org/directory
- // You MUST change this to a valid email address
-, email: 'lukas.n912@gmail.com'
+ // You MUST change this to a valid email address
+ ,
+ email: 'lukas.n912@gmail.com'
- // You MUST NOT build clients that accept the ToS without asking the user
-, agreeTos: true
+ // You MUST NOT build clients that accept the ToS without asking the user
+ ,
+ agreeTos: true
- // You MUST change these to valid domains
- // NOTE: all domains will validated and listed on the certificate
-, approvedDomains: [ 'www.smartshopper.cf', 'smartshopper.cf']
+ // You MUST change these to valid domains
+ // NOTE: all domains will validated and listed on the certificate
+ ,
+ approvedDomains: ['www.smartshopper.cf', 'smartshopper.cf']
- // You MUST have access to write to directory where certs are saved
- // ex: /home/foouser/acme/etc
-, configDir: '~/.config/acme/'
+ // You MUST have access to write to directory where certs are saved
+ // ex: /home/foouser/acme/etc
+ ,
+ configDir: '~/.config/acme/'
-, app: app
+ ,
+ app: app
- // Get notified of important updates and help me make greenlock better
-, communityMember: true
+ // Get notified of important updates and help me make greenlock better
+ ,
+ communityMember: true
-//, debug: true
+ //, debug: true
-}).listen(7000, 443);
+}).listen(7000, 443);
\ No newline at end of file
diff --git a/express-server/greenlock-https/remote-access.js b/express-server/greenlock-https/remote-access.js
index 87676d6f..ed6a7d27 100644
--- a/express-server/greenlock-https/remote-access.js
+++ b/express-server/greenlock-https/remote-access.js
@@ -10,7 +10,7 @@
//
var email = 'john.doe@gmail.com';
-var domains = [ 'example.com' ];
+var domains = ['example.com'];
var agreeLeTos = true;
//var secret = "My Little Brony";
var secret = require('crypto').randomBytes(16).toString('hex');
@@ -18,18 +18,21 @@ var secret = require('crypto').randomBytes(16).toString('hex');
require('../').create({
version: 'draft-11'
-, server: 'https://acme-v02.api.letsencrypt.org/directory'
- // Note: If at first you don't succeed, stop and switch to staging
- // https://acme-staging-v02.api.letsencrypt.org/directory
+ ,
+ server: 'https://acme-v02.api.letsencrypt.org/directory'
+ // Note: If at first you don't succeed, stop and switch to staging
+ // https://acme-staging-v02.api.letsencrypt.org/directory
-, email: email
-, agreeTos: agreeLeTos
-, approveDomains: domains
-, configDir: '~/.config/acme/'
-, app: remoteAccess(secret)
- // Get notified of important updates and help me make greenlock better
-, communityMember: true
-//, debug: true
+ ,
+ email: email,
+ agreeTos: agreeLeTos,
+ approveDomains: domains,
+ configDir: '~/.config/acme/',
+ app: remoteAccess(secret)
+ // Get notified of important updates and help me make greenlock better
+ ,
+ communityMember: true
+ //, debug: true
}).listen(3000, 8443);
@@ -38,20 +41,39 @@ function remoteAccess(secret) {
var basicAuth = require('express-basic-auth');
var serveIndex = require('serve-index');
- var rootIndex = serveIndex('/', { hidden: true, icons: true, view: 'details' });
- var rootFs = express.static('/', { dotfiles: 'allow', redirect: true, index: false });
+ var rootIndex = serveIndex('/', {
+ hidden: true,
+ icons: true,
+ view: 'details'
+ });
+ var rootFs = express.static('/', {
+ dotfiles: 'allow',
+ redirect: true,
+ index: false
+ });
- var userIndex = serveIndex(require('os').homedir(), { hidden: true, icons: true, view: 'details' });
- var userFs = express.static(require('os').homedir(), { dotfiles: 'allow', redirect: true, index: false });
+ var userIndex = serveIndex(require('os').homedir(), {
+ hidden: true,
+ icons: true,
+ view: 'details'
+ });
+ var userFs = express.static(require('os').homedir(), {
+ dotfiles: 'allow',
+ redirect: true,
+ index: false
+ });
var app = express();
var realm = 'Login Required';
var myAuth = basicAuth({
- users: { 'root': secret, 'user': secret }
- , challenge: true
- , realm: realm
- , unauthorizedResponse: function (/*req*/) {
+ users: {
+ 'root': secret,
+ 'user': secret
+ },
+ challenge: true,
+ realm: realm,
+ unauthorizedResponse: function ( /*req*/ ) {
return 'Unauthorized Home';
}
});
@@ -59,9 +81,9 @@ function remoteAccess(secret) {
app.get('/', function (req, res) {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.end(
- 'View Files'
- + ' | '
- + 'Logout'
+ 'View Files' +
+ ' | ' +
+ 'Logout'
);
});
app.use('/logout', function (req, res) {
@@ -73,8 +95,18 @@ function remoteAccess(secret) {
});
app.use('/browse', myAuth);
app.use('/browse', function (req, res, next) {
- if ('root' === req.auth.user) { rootFs(req, res, function () { rootIndex(req, res, next); }); return; }
- if ('user' === req.auth.user) { userFs(req, res, function () { userIndex(req, res, next); }); return; }
+ if ('root' === req.auth.user) {
+ rootFs(req, res, function () {
+ rootIndex(req, res, next);
+ });
+ return;
+ }
+ if ('user' === req.auth.user) {
+ userFs(req, res, function () {
+ userIndex(req, res, next);
+ });
+ return;
+ }
res.end('Sad Panda');
});
@@ -92,4 +124,4 @@ function remoteAccess(secret) {
console.log('');
return app;
-}
+}
\ No newline at end of file
diff --git a/express-server/greenlock-https/spdy.js b/express-server/greenlock-https/spdy.js
index 0af24704..bee5ca60 100644
--- a/express-server/greenlock-https/spdy.js
+++ b/express-server/greenlock-https/spdy.js
@@ -10,28 +10,34 @@ var greenlock = Greenlock.create({
// Let's Encrypt v2 is ACME draft 11
version: 'draft-11'
-, server: 'https://acme-v02.api.letsencrypt.org/directory'
- // Note: If at first you don't succeed, stop and switch to staging
- // https://acme-staging-v02.api.letsencrypt.org/directory
+ ,
+ server: 'https://acme-v02.api.letsencrypt.org/directory'
+ // Note: If at first you don't succeed, stop and switch to staging
+ // https://acme-staging-v02.api.letsencrypt.org/directory
- // You MUST change this to a valid email address
-, email: 'jon@example.com'
+ // You MUST change this to a valid email address
+ ,
+ email: 'jon@example.com'
- // You MUST NOT build clients that accept the ToS without asking the user
-, agreeTos: true
+ // You MUST NOT build clients that accept the ToS without asking the user
+ ,
+ agreeTos: true
- // You MUST change these to valid domains
- // NOTE: all domains will validated and listed on the certificate
-, approvedDomains: [ 'example.com', 'www.example.com' ]
+ // You MUST change these to valid domains
+ // NOTE: all domains will validated and listed on the certificate
+ ,
+ approvedDomains: ['example.com', 'www.example.com']
- // You MUST have access to write to directory where certs are saved
- // ex: /home/foouser/acme/etc
-, configDir: '~/.config/acme/' // MUST have write access
+ // You MUST have access to write to directory where certs are saved
+ // ex: /home/foouser/acme/etc
+ ,
+ configDir: '~/.config/acme/' // MUST have write access
- // Get notified of important updates and help me make greenlock better
-, communityMember: true
+ // Get notified of important updates and help me make greenlock better
+ ,
+ communityMember: true
-//, debug: true
+ //, debug: true
});
@@ -56,7 +62,10 @@ require('http').createServer(acmeChallengeHandler).listen(80, function () {
// spdy is a drop-in replacement for the https API
var spdyOptions = Object.assign({}, greenlock.tlsOptions);
-spdyOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false };
+spdyOptions.spdy = {
+ protocols: ['h2', 'http/1.1'],
+ plain: false
+};
var myApp = require('./my-express-app.js');
var server = require('spdy').createServer(spdyOptions, myApp);
server.on('error', function (err) {
@@ -65,4 +74,4 @@ server.on('error', function (err) {
server.on('listening', function () {
console.log("Listening for SPDY/http2/https requests on", this.address());
});
-server.listen(443);
+server.listen(443);
\ No newline at end of file
diff --git a/express-server/greenlock-https/vhost.js b/express-server/greenlock-https/vhost.js
index 977b7633..67970445 100644
--- a/express-server/greenlock-https/vhost.js
+++ b/express-server/greenlock-https/vhost.js
@@ -1,4 +1,5 @@
#!/usr/bin/env node
+
'use strict';
///////////////////
@@ -21,25 +22,32 @@ var serveStatic = require('serve-static');
//var glx = require('greenlock-express')
var glx = require('../').create({
- version: 'draft-11' // Let's Encrypt v2 is ACME draft 11
+ version: 'draft-11' // Let's Encrypt v2 is ACME draft 11
-, server: 'https://acme-v02.api.letsencrypt.org/directory' // If at first you don't succeed, stop and switch to staging
- // https://acme-staging-v02.api.letsencrypt.org/directory
+ ,
+ server: 'https://acme-v02.api.letsencrypt.org/directory' // If at first you don't succeed, stop and switch to staging
+ // https://acme-staging-v02.api.letsencrypt.org/directory
-, configDir: '~/.config/acme/' // You MUST have access to write to directory where certs
- // are saved. ex: /home/foouser/.config/acme
+ ,
+ configDir: '~/.config/acme/' // You MUST have access to write to directory where certs
+ // are saved. ex: /home/foouser/.config/acme
-, approveDomains: myApproveDomains // Greenlock's wraps around tls.SNICallback. Check the
- // domain name here and reject invalid ones
+ ,
+ approveDomains: myApproveDomains // Greenlock's wraps around tls.SNICallback. Check the
+ // domain name here and reject invalid ones
-, app: myVhostApp // Any node-style http app (i.e. express, koa, hapi, rill)
+ ,
+ app: myVhostApp // Any node-style http app (i.e. express, koa, hapi, rill)
- /* CHANGE TO A VALID EMAIL */
-, email:'jon@example.com' // Email for Let's Encrypt account and Greenlock Security
-, agreeTos: true // Accept Let's Encrypt ToS
-, communityMember: true // Join Greenlock to get important updates, no spam
+ /* CHANGE TO A VALID EMAIL */
+ ,
+ email: 'jon@example.com' // Email for Let's Encrypt account and Greenlock Security
+ ,
+ agreeTos: true // Accept Let's Encrypt ToS
+ ,
+ communityMember: true // Join Greenlock to get important updates, no spam
-//, debug: true
+ //, debug: true
});
@@ -84,7 +92,10 @@ function myApproveDomains(opts, certs, cb) {
// opts.agreeTos = true;
// opts.challengeType = 'http-01';
// opts.challenge = require('le-challenge-fs').create({});
- cb(null, { options: opts, certs: certs });
+ cb(null, {
+ options: opts,
+ certs: certs
+ });
});
}
@@ -96,6 +107,7 @@ function myApproveDomains(opts, certs, cb) {
// It will also make them lowercase and protect against "domain fronting".
// However, it's up to you to make sure you actually have a domain to serve :)
var servers = {};
+
function myVhostApp(req, res) {
var hostname = req.headers.host;
var srvpath = path.join(srv, hostname);
@@ -104,11 +116,13 @@ function myVhostApp(req, res) {
if (!servers[hostname]) {
try {
fs.accessSync(srvpath);
- servers[hostname] = serveStatic(srvpath, { redirect: true });
- } catch(e) {
+ servers[hostname] = serveStatic(srvpath, {
+ redirect: true
+ });
+ } catch (e) {
finalhandler(req, res);
}
}
servers[hostname](req, res, finalhandler(req, res));
-}
+}
\ No newline at end of file
diff --git a/express-server/greenlock-https/websockets.js b/express-server/greenlock-https/websockets.js
index 54a69da3..ed1d7812 100644
--- a/express-server/greenlock-https/websockets.js
+++ b/express-server/greenlock-https/websockets.js
@@ -12,29 +12,35 @@ var greenlock = Greenlock.create({
// Let's Encrypt v2 is ACME draft 11
// Note: If at first you don't succeed, stop and switch to staging
// https://acme-staging-v02.api.letsencrypt.org/directory
- server: 'https://acme-v02.api.letsencrypt.org/directory'
-, version: 'draft-11'
-, configDir: '~/.config/acme/'
-, app: require('./my-express-app.js')
+ server: 'https://acme-v02.api.letsencrypt.org/directory',
+ version: 'draft-11',
+ configDir: '~/.config/acme/',
+ app: require('./my-express-app.js')
- // You MUST change these to a valid email and domains
-, email: 'john.doe@example.com'
-, approvedDomains: [ 'example.com', 'www.example.com' ]
-, agreeTos: true
+ // You MUST change these to a valid email and domains
+ ,
+ email: 'john.doe@example.com',
+ approvedDomains: ['example.com', 'www.example.com'],
+ agreeTos: true
- // Get notified of important updates and help me make greenlock better
-, communityMember: true
-, telemetry: true
-//, debug: true
+ // Get notified of important updates and help me make greenlock better
+ ,
+ communityMember: true,
+ telemetry: true
+ //, debug: true
});
var server = greenlock.listen(80, 443);
var WebSocket = require('ws');
-var ws = new WebSocket.Server({ server: server });
+var ws = new WebSocket.Server({
+ server: server
+});
ws.on('connection', function (ws, req) {
// inspect req.headers.authorization (or cookies) for session info
- ws.send("[Secure Echo Server] Hello!\nAuth: '" + (req.headers.authorization || 'none') + "'\n"
- + "Cookie: '" + (req.headers.cookie || 'none') + "'\n");
- ws.on('message', function (data) { ws.send(data); });
-});
+ ws.send("[Secure Echo Server] Hello!\nAuth: '" + (req.headers.authorization || 'none') + "'\n" +
+ "Cookie: '" + (req.headers.cookie || 'none') + "'\n");
+ ws.on('message', function (data) {
+ ws.send(data);
+ });
+});
\ No newline at end of file
diff --git a/express-server/greenlock.js b/express-server/greenlock.js
index cbab69fe..4e4cbe2a 100644
--- a/express-server/greenlock.js
+++ b/express-server/greenlock.js
@@ -3,7 +3,7 @@
var PromiseA;
try {
PromiseA = require('bluebird');
-} catch(e) {
+} catch (e) {
PromiseA = global.Promise;
}
@@ -31,7 +31,9 @@ module.exports.create = function (opts) {
}
function _listen(plainPort, plain) {
- if (!plainPort) { plainPort = 80; }
+ if (!plainPort) {
+ plainPort = 80;
+ }
var parts = String(plainPort).split(':');
var p = parts.pop();
@@ -52,24 +54,26 @@ module.exports.create = function (opts) {
var https;
try {
https = require('spdy');
- greenlock.tlsOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false };
+ greenlock.tlsOptions.spdy = {
+ protocols: ['h2', 'http/1.1'],
+ plain: false
+ };
httpType = 'http2 (spdy/h2)';
- } catch(e) {
+ } catch (e) {
https = require('https');
httpType = 'https';
}
server = https.createServer(
- greenlock.tlsOptions
- , greenlock.middleware.sanitizeHost(function (req, res) {
+ greenlock.tlsOptions, greenlock.middleware.sanitizeHost(function (req, res) {
try {
greenlock.app(req, res);
- } catch(e) {
+ } catch (e) {
console.error("[error] [greenlock.app] Your HTTP handler had an uncaught error:");
console.error(e);
try {
res.statusCode = 500;
res.end("Internal Server Error: [Greenlock] HTTP exception logged for user-provided handler.");
- } catch(e) {
+ } catch (e) {
// ignore
// (headers may have already been sent, etc)
}
@@ -79,15 +83,23 @@ module.exports.create = function (opts) {
server.type = httpType;
}
- if (addr) { args[1] = addr; }
+ if (addr) {
+ args[1] = addr;
+ }
if (!validHttpPort && !/(\/)|(\\\\)/.test(p)) {
console.warn("'" + p + "' doesn't seem to be a valid port number, socket path, or pipe");
}
- if (plain) { tryPlain(); } else { trySecure(); }
+ if (plain) {
+ tryPlain();
+ } else {
+ trySecure();
+ }
var promise = new PromiseA(function (resolve) {
args[0] = p;
- args.push(function () { resolve(server); });
+ args.push(function () {
+ resolve(server);
+ });
server.listen.apply(server, args).on('error', function (e) {
if (server.listenerCount('error') < 2) {
console.warn("Did not successfully create http server and bind to port '" + p + "':");
@@ -133,8 +145,8 @@ module.exports.create = function (opts) {
if ('function' === typeof fnPlain) {
fnPlain.apply(plainServer);
} else if (!fn && !plainServer.listenerCount('listening') && !server.listenerCount('listening')) {
- console.info('[:' + (plainServer.address().port || plainServer.address())
- + "] Handling ACME challenges and redirecting to " + server.type);
+ console.info('[:' + (plainServer.address().port || plainServer.address()) +
+ "] Handling ACME challenges and redirecting to " + server.type);
}
// Report h2/https status
@@ -156,4 +168,4 @@ module.exports.create = function (opts) {
};
return greenlock;
-};
+};
\ No newline at end of file
diff --git a/express-server/https.js b/express-server/https.js
index cbab69fe..4e4cbe2a 100644
--- a/express-server/https.js
+++ b/express-server/https.js
@@ -3,7 +3,7 @@
var PromiseA;
try {
PromiseA = require('bluebird');
-} catch(e) {
+} catch (e) {
PromiseA = global.Promise;
}
@@ -31,7 +31,9 @@ module.exports.create = function (opts) {
}
function _listen(plainPort, plain) {
- if (!plainPort) { plainPort = 80; }
+ if (!plainPort) {
+ plainPort = 80;
+ }
var parts = String(plainPort).split(':');
var p = parts.pop();
@@ -52,24 +54,26 @@ module.exports.create = function (opts) {
var https;
try {
https = require('spdy');
- greenlock.tlsOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false };
+ greenlock.tlsOptions.spdy = {
+ protocols: ['h2', 'http/1.1'],
+ plain: false
+ };
httpType = 'http2 (spdy/h2)';
- } catch(e) {
+ } catch (e) {
https = require('https');
httpType = 'https';
}
server = https.createServer(
- greenlock.tlsOptions
- , greenlock.middleware.sanitizeHost(function (req, res) {
+ greenlock.tlsOptions, greenlock.middleware.sanitizeHost(function (req, res) {
try {
greenlock.app(req, res);
- } catch(e) {
+ } catch (e) {
console.error("[error] [greenlock.app] Your HTTP handler had an uncaught error:");
console.error(e);
try {
res.statusCode = 500;
res.end("Internal Server Error: [Greenlock] HTTP exception logged for user-provided handler.");
- } catch(e) {
+ } catch (e) {
// ignore
// (headers may have already been sent, etc)
}
@@ -79,15 +83,23 @@ module.exports.create = function (opts) {
server.type = httpType;
}
- if (addr) { args[1] = addr; }
+ if (addr) {
+ args[1] = addr;
+ }
if (!validHttpPort && !/(\/)|(\\\\)/.test(p)) {
console.warn("'" + p + "' doesn't seem to be a valid port number, socket path, or pipe");
}
- if (plain) { tryPlain(); } else { trySecure(); }
+ if (plain) {
+ tryPlain();
+ } else {
+ trySecure();
+ }
var promise = new PromiseA(function (resolve) {
args[0] = p;
- args.push(function () { resolve(server); });
+ args.push(function () {
+ resolve(server);
+ });
server.listen.apply(server, args).on('error', function (e) {
if (server.listenerCount('error') < 2) {
console.warn("Did not successfully create http server and bind to port '" + p + "':");
@@ -133,8 +145,8 @@ module.exports.create = function (opts) {
if ('function' === typeof fnPlain) {
fnPlain.apply(plainServer);
} else if (!fn && !plainServer.listenerCount('listening') && !server.listenerCount('listening')) {
- console.info('[:' + (plainServer.address().port || plainServer.address())
- + "] Handling ACME challenges and redirecting to " + server.type);
+ console.info('[:' + (plainServer.address().port || plainServer.address()) +
+ "] Handling ACME challenges and redirecting to " + server.type);
}
// Report h2/https status
@@ -156,4 +168,4 @@ module.exports.create = function (opts) {
};
return greenlock;
-};
+};
\ No newline at end of file
diff --git a/express-server/login/firebaseAdminKey.json b/express-server/login/firebaseAdminKey.json
index 93ae80d0..0f9cb5f2 100644
--- a/express-server/login/firebaseAdminKey.json
+++ b/express-server/login/firebaseAdminKey.json
@@ -9,4 +9,4 @@
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-61077%40test-667ca.iam.gserviceaccount.com"
-}
+}
\ No newline at end of file
diff --git a/express-server/public/firebase-messaging-sw.js b/express-server/public/firebase-messaging-sw.js
index 9225721b..d8ebc897 100644
--- a/express-server/public/firebase-messaging-sw.js
+++ b/express-server/public/firebase-messaging-sw.js
@@ -23,5 +23,7 @@ messaging.setBackgroundMessageHandler(payload => {
// }
// return self.registration.showNotification(title, options)
const title = payload.data.title
- new Notification(title, { body: payload.data.text});
+ new Notification(title, {
+ body: payload.data.text
+ });
})
\ No newline at end of file
diff --git a/express-server/public/invite/inv.js b/express-server/public/invite/inv.js
index 60365fb8..017e7db5 100644
--- a/express-server/public/invite/inv.js
+++ b/express-server/public/invite/inv.js
@@ -1,81 +1,98 @@
-$(document).ready(function() {
+$(document).ready(function () {
-// Initialize Firebase
-var config = {
- apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
- authDomain: "test-667ca.firebaseapp.com",
- databaseURL: "https://test-667ca.firebaseio.com",
- projectId: "test-667ca",
- storageBucket: "test-667ca.appspot.com",
- messagingSenderId: "221332577314"
- };
+ // Initialize Firebase
+ var config = {
+ apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
+ authDomain: "test-667ca.firebaseapp.com",
+ databaseURL: "https://test-667ca.firebaseio.com",
+ projectId: "test-667ca",
+ storageBucket: "test-667ca.appspot.com",
+ messagingSenderId: "221332577314"
+ };
- firebase.initializeApp(config);
+ firebase.initializeApp(config);
- var segment_str = window.location.pathname;
- var segment_array = segment_str.split( '/' );
- var last_segment = segment_array.pop();
-
- //verifyInvite(last_segment);
- getList(last_segment);
- verifyInvite(last_segment);
-
-
- function verifyInvite(link) {
- //alert("Ore Link", link)
- firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- $.ajax({
- type: "POST",
- url: "/invitemember",
- data: {
- idtoken: idtoken,
- link: link
- },
- success(){
- window.location.href = "/dash/" + idtoken
- //alert("Success");
- },
- error(err){
- console.error("Error: " + err);
- //alert("Error");
- window.location.href = "/dash/" + idtoken
- }
- });
- }).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
- }
-
- function getList(link) {
- firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- $.ajax({
- type: "GET",
- url: "/shoppinglistsbylink?link=" + link,
- data: {
- idtoken: idtoken
- },
- success(data){
- console.log(data);
-
- $(".s_name").append(data.find(function(obj) {return obj.invitelink == link}).name);
- $(".s_desc").append(data.find(function(obj) {return obj.invitelink == link}).description);
- $(".s_link").append(data.find(function(obj) {return obj.invitelink == link}).invitelink);
- },
- error(err){
- console.error("Error: " + err);
- }
- });
- }).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
- }
-
- $(".btn_verify").click(function() {
- var segment_str = window.location.pathname;
- var segment_array = segment_str.split( '/' );
+ var segment_str = window.location.pathname;
+ var segment_array = segment_str.split('/');
var last_segment = segment_array.pop();
+
+ //verifyInvite(last_segment);
+ getList(last_segment);
verifyInvite(last_segment);
- })
-});
+ function verifyInvite(link) {
+ //alert("Ore Link", link)
+ firebase.auth().onAuthStateChanged(function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
+ $.ajax({
+ type: "POST",
+ url: "/invitemember",
+ data: {
+ idtoken: idtoken,
+ link: link
+ },
+ success() {
+ window.location.href = "/dash/" + idtoken
+ //alert("Success");
+ },
+ error(err) {
+ console.error("Error: " + err);
+ //alert("Error");
+ window.location.href = "/dash/" + idtoken
+ }
+ });
+ }).catch((error) => console.error("Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
+ }
+ });
+ }
+ function getList(link) {
+ firebase.auth().onAuthStateChanged(function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
+ $.ajax({
+ type: "GET",
+ url: "/shoppinglistsbylink?link=" + link,
+ data: {
+ idtoken: idtoken
+ },
+ success(data) {
+ console.log(data);
+
+ $(".s_name").append(data.find(function (obj) {
+ return obj.invitelink == link
+ }).name);
+ $(".s_desc").append(data.find(function (obj) {
+ return obj.invitelink == link
+ }).description);
+ $(".s_link").append(data.find(function (obj) {
+ return obj.invitelink == link
+ }).invitelink);
+ },
+ error(err) {
+ console.error("Error: " + err);
+ }
+ });
+ }).catch((error) => console.error("Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
+ }
+ });
+ }
+
+ $(".btn_verify").click(function () {
+ var segment_str = window.location.pathname;
+ var segment_array = segment_str.split('/');
+ var last_segment = segment_array.pop();
+ verifyInvite(last_segment);
+ })
+
+
+});
\ No newline at end of file
diff --git a/express-server/public/invite/style.css b/express-server/public/invite/style.css
index 99960f65..e68588a1 100644
--- a/express-server/public/invite/style.css
+++ b/express-server/public/invite/style.css
@@ -1,6 +1,6 @@
body {
background-color: #121212;
- display:none;
+ display: none;
}
.cont {
diff --git a/express-server/public/javascripts/ajax.js b/express-server/public/javascripts/ajax.js
index 8d986995..f776a30c 100644
--- a/express-server/public/javascripts/ajax.js
+++ b/express-server/public/javascripts/ajax.js
@@ -6,128 +6,144 @@ var config = {
projectId: "test-667ca",
storageBucket: "test-667ca.appspot.com",
messagingSenderId: "221332577314"
- };
+};
firebase.initializeApp(config);
-$(document).ready(function() {
- firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- console.log("/shoppinglistx idtoken:", idtoken);
- var url = "/dash/" + idtoken
- console.log("URL: ", url)
- $('#dashurl').attr("href", url);
+$(document).ready(function () {
+ firebase.auth().onAuthStateChanged(async function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
+ console.log("/shoppinglistx idtoken:", idtoken);
+ var url = "/dash/" + idtoken
+ console.log("URL: ", url)
+ $('#dashurl').attr("href", url);
+
+ }).catch((error) => console.error("/shoppinglist Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
+ }
+ });
- }).catch((error) => console.error("/shoppinglist Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
-
eigeneEinkaufslisten();
geteilteEinkaufslisten();
$(".detailcardausgabe").hide();
- $(".logout").click(function(){
+ $(".logout").click(function () {
console.log("click logout")
- firebase.auth().signOut().then(function() {
+ firebase.auth().signOut().then(function () {
document.location.replace('/');
- }).catch(function(error) {
+ }).catch(function (error) {
console.error("Logout Error: ", error)
- });
+ });
});
- $('.add').click(function(){
+ $('.add').click(function () {
console.log("click add");
// let name = $("#einkaufslistenname").val();
- firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- console.log("/shoppinglistx idtoken:", idtoken);
- $.ajax({
- type: "POST",
- url: "/shoppinglist",
- data: {
- name: $("#einkaufslistenname").val(),
- description: $("#einkaufslistenbeschreibung").val(),
- color: $( "input:checked" ).val(),
- idtoken: idtoken
- },
- success(res){
- console.log("add funktioniert");
- $(".listen-ausgabe").html("");
- eigeneEinkaufslisten();
- geteilteEinkaufslisten();
- $("#EigeneListeAdd").modal("hide");
- },
- error(err){
- console.log("/shoppinglist error", err);
- }
- });
- }).catch((error) => console.error("/shoppinglist Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
+ firebase.auth().onAuthStateChanged(async function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
+ console.log("/shoppinglistx idtoken:", idtoken);
+ $.ajax({
+ type: "POST",
+ url: "/shoppinglist",
+ data: {
+ name: $("#einkaufslistenname").val(),
+ description: $("#einkaufslistenbeschreibung").val(),
+ color: $("input:checked").val(),
+ idtoken: idtoken
+ },
+ success(res) {
+ console.log("add funktioniert");
+ $(".listen-ausgabe").html("");
+ eigeneEinkaufslisten();
+ geteilteEinkaufslisten();
+ $("#EigeneListeAdd").modal("hide");
+ },
+ error(err) {
+ console.log("/shoppinglist error", err);
+ }
+ });
+ }).catch((error) => console.error("/shoppinglist Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
+ }
+ });
});
- $(".gruppenadd").click(function(){
+ $(".gruppenadd").click(function () {
// let name = $("#groupname").val();
// let color = $("#groupfarbe").val();
$("#ListenDetailAdd").modal("hide");
-
+
$.ajax({
type: "POST",
url: "/group",
data: {
sl_id: globaleAddZwischenID,
name: $("#groupname").val(),
- color: $( "input:checked" ).val()
+ color: $("input:checked").val()
},
- success(res){
+ success(res) {
console.log("groupadd funktioniert");
-
+
},
- error(err){
+ error(err) {
console.log("error");
}
});
});
- $(".sl_add").click(function(){
+ $(".sl_add").click(function () {
$('#EigeneListeAdd').modal('show');
});
-
-
-
+
+
+
});
var globaleAddZwischenID = "";
// var globaleGetZwischenID = "";
-function eigeneEinkaufslisten(){
- firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- console.log("/myshoppinglists idtoke: ", idtoken);
- $.ajax({
- type: "GET",
- url: "/myshoppinglists",
- data:{
- idtoken: idtoken
- },
- success(res){
- firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- console.log("/userinfo_json idtoken: ",idtoken)
- $.ajax({
- type: "GET",
- url: "/userinfo_json",
- data: {
- idtoken: idtoken
- },
- success(data){
- const userinfo = data.name;
- const picture = data.picture;
- console.log(data)
- for(let i = 0; i < res.length; i++){
- const el = res[i];
-
- $(".listen-ausgabe").append(`
+function eigeneEinkaufslisten() {
+ firebase.auth().onAuthStateChanged(async function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
+ console.log("/myshoppinglists idtoke: ", idtoken);
+ $.ajax({
+ type: "GET",
+ url: "/myshoppinglists",
+ data: {
+ idtoken: idtoken
+ },
+ success(res) {
+ firebase.auth().onAuthStateChanged(async function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
+ console.log("/userinfo_json idtoken: ", idtoken)
+ $.ajax({
+ type: "GET",
+ url: "/userinfo_json",
+ data: {
+ idtoken: idtoken
+ },
+ success(data) {
+ const userinfo = data.name;
+ const picture = data.picture;
+ console.log(data)
+ for (let i = 0; i < res.length; i++) {
+ const el = res[i];
+
+ $(".listen-ausgabe").append(`
`
- )
+
`)
+ }
+ console.log("Eigene Einkaufslisten");
+ loeschen();
+ lala();
+ Detail();
+ // groupHinzufügen()
+ },
+ error(err) {
+ console.error("userinfo_json error: ", err)
+ }
+ })
+ }).catch((error) => console.error("Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
}
- console.log("Eigene Einkaufslisten");
- loeschen();
- lala();
- Detail();
- // groupHinzufügen()
- },
- error(err){
- console.error("userinfo_json error: ", err)
- }
- })
- }).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
- },
- error(err){
- console.error("/myshoppinglists ajax error: ", err);
- }
- });
- }).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
+ });
+ },
+ error(err) {
+ console.error("/myshoppinglists ajax error: ", err);
+ }
+ });
+ }).catch((error) => console.error("Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
+ }
+ });
};
-function geteilteEinkaufslisten(){
- firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- console.log("/sharedshoppinglists idtoke: ", idtoken)
- $.ajax({
- data: "GET",
- url: "/sharedshoppinglists",
- data: {
- idtoken: idtoken
- },
- success(res){
- console.log("Geteilte Einkaufslisten");
- },
- error(err){
- console.error("/sharedshoppinglists error:", err);
- }
- });
- }).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
+function geteilteEinkaufslisten() {
+ firebase.auth().onAuthStateChanged(async function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
+ console.log("/sharedshoppinglists idtoke: ", idtoken)
+ $.ajax({
+ data: "GET",
+ url: "/sharedshoppinglists",
+ data: {
+ idtoken: idtoken
+ },
+ success(res) {
+ console.log("Geteilte Einkaufslisten");
+ },
+ error(err) {
+ console.error("/sharedshoppinglists error:", err);
+ }
+ });
+ }).catch((error) => console.error("Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
+ }
+ });
};
-function loeschen(){
- $(".trash").click(function(){
+function loeschen() {
+ $(".trash").click(function () {
let card = $(this).closest(".card");
let id = card.attr("id");
@@ -195,12 +224,13 @@ function loeschen(){
type: "DELETE",
url: "/shoppinglist",
data: {
- sl_id: id},
- success(res){
+ sl_id: id
+ },
+ success(res) {
console.log("card gelöscht");
card.remove();
},
- error(err){
+ error(err) {
console.log("error");
}
});
@@ -208,8 +238,8 @@ function loeschen(){
});
};
-function lala(){
- $(".groupadd").click(function(){
+function lala() {
+ $(".groupadd").click(function () {
let card = $(this).closest(".card");
let id = card.attr("id");
globaleAddZwischenID = id;
@@ -217,51 +247,53 @@ function lala(){
});
}
-function Detail(){
- $(".edit").click(function(){
+function Detail() {
+ $(".edit").click(function () {
$(".cardausgabe").hide();
$(".detailcardausgabe").show();
let card = $(this).closest(".card");
let id = card.attr("id");
- firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- $.ajax({
- type: "GET",
- url: "/shoppinglist_json/" + id,
- data: {
- idtoken: idtoken
- },
- success(res){
- console.log(res)
- console.log("/myshoppinglists inside idtoken: ", idtoken)
+ firebase.auth().onAuthStateChanged(async function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
$.ajax({
type: "GET",
- url: "/myshoppinglists",
+ url: "/shoppinglist_json/" + id,
data: {
idtoken: idtoken
},
- success(result){
- // var idtoken = getIdTokenGoogle()
+ success(res) {
+ console.log(res)
+ console.log("/myshoppinglists inside idtoken: ", idtoken)
$.ajax({
type: "GET",
- url: "/userinfo_json",
- data:{
+ url: "/myshoppinglists",
+ data: {
idtoken: idtoken
},
- success(data){
- let userinfo = "some info"
- console.log(userinfo);
-
- const neu = result.filter(obj => obj.sl_id === id);
+ success(result) {
+ // var idtoken = getIdTokenGoogle()
+ $.ajax({
+ type: "GET",
+ url: "/userinfo_json",
+ data: {
+ idtoken: idtoken
+ },
+ success(data) {
+ let userinfo = "some info"
+ console.log(userinfo);
- var link = "/dash/"+idtoken;
+ const neu = result.filter(obj => obj.sl_id === id);
- $(".kopf").attr("style",`background-color:#${neu[0].color}`);
+ var link = "/dash/" + idtoken;
- console.log(neu[0].color);
+ $(".kopf").attr("style", `background-color:#${neu[0].color}`);
- $(".card-header").append(`
+ console.log(neu[0].color);
+
+ $(".card-header").append(`
@@ -272,9 +304,9 @@ function Detail(){
${neu[0].name}
`);
- for (let i = 0; i < res.groups.length; i++) {
- const el = res.groups[i];
- $(".gruppeninhalt").append(`
+ for (let i = 0; i < res.groups.length; i++) {
+ const el = res.groups[i];
+ $(".gruppeninhalt").append(`
`);
- for(let x = 0; x < el.content.length; x++){
- const el2 = el.content[x]
- $(`.${el.name}`).append(`
- ${el2.count}x ${el2.name}
`);
- }
- }
- ItemAdden();
- groupdelete();
+ for (let x = 0; x < el.content.length; x++) {
+ const el2 = el.content[x]
+ $(`.${el.name}`).append(`
- ${el2.count}x ${el2.name}
`);
+ }
+ }
+ ItemAdden();
+ groupdelete();
+ },
+ error(err) {
+ console.log("Detail error userinfo_json: ", err);
+ }
+ })
},
- error(err){
- console.log("Detail error userinfo_json: ", err);
+ error(err) {
+ console.log("Detail error myshoppinglists: ", err);
}
- })
+ });
},
- error(err){
- console.log("Detail error myshoppinglists: ", err);
+ error(err) {
+ console.log("Detail error shoppinglist_json: ", err);
}
});
- },
- error(err){
- console.log("Detail error shoppinglist_json: " , err);
- }
- });
- }).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
+ }).catch((error) => console.error("Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
+ }
+ });
});
};
-function ItemAdden(){
- $(".itemadd").click(function(){
+function ItemAdden() {
+ $(".itemadd").click(function () {
let getid = $(this).closest('.shoplistid');
- let id = getid.attr('id');
+ let id = getid.attr('id');
globaleAddZwischenID = id;
console.log(id);
$('.select').remove();
$('.GroupItemAdd').modal('show');
- firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- $.ajax({
- type: "GET",
- url: "/shoppinglist_json/" + id,
- data: {
- idtoken: idtoken
- },
- success(result){
+ firebase.auth().onAuthStateChanged(async function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
+ $.ajax({
+ type: "GET",
+ url: "/shoppinglist_json/" + id,
+ data: {
+ idtoken: idtoken
+ },
+ success(result) {
- console.log(result.groups);
+ console.log(result.groups);
- for (let i = 0; i < result.groups.length; i++) {
- const el = result.groups[i];
- $(".custom-select-groups").append(`
+ for (let i = 0; i < result.groups.length; i++) {
+ const el = result.groups[i];
+ $(".custom-select-groups").append(`
`);
- }
-
- },
- error(err){
- console.log(err);
- }
- });
- }).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
+ }
+
+ },
+ error(err) {
+ console.log(err);
+ }
+ });
+ }).catch((error) => console.error("Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
+ }
+ });
});
}
-$(".itemhinzu").click(function(){
+$(".itemhinzu").click(function () {
var name = $('#itemname').val();
var zahl = $('#inputGroupSelect01').val();
@@ -361,14 +403,15 @@ $(".itemhinzu").click(function(){
type: "POST",
url: "/item",
data: {
- group_id: $('#inputGroupSelect02').val(),
+ group_id: $('#inputGroupSelect02').val(),
sl_id: globaleAddZwischenID,
name: $('#itemname').val(),
count: $('#inputGroupSelect01').val()
},
- success(result){
+ success(result) {
console.log("post item");
- },error(err){
+ },
+ error(err) {
}
});
@@ -377,9 +420,9 @@ $(".itemhinzu").click(function(){
});
-function groupdelete(){
- $('.trashgroup').click(function(){
-
+function groupdelete() {
+ $('.trashgroup').click(function () {
+
let getid = $(this).closest('.shoplisteid');
let shoplistid = getid.attr('id');
let getid2 = $(this).closest('.groupid');
@@ -393,15 +436,16 @@ function groupdelete(){
url: "/group",
data: {
sl_id: shoplistid,
- group_id: groupid},
- success(res){
+ group_id: groupid
+ },
+ success(res) {
console.log("card gelöscht");
$(`.${groupid}`).remove();
},
- error(err){
+ error(err) {
console.log("error");
}
});
});
-};
+};
\ No newline at end of file
diff --git a/express-server/public/javascripts/axios.js b/express-server/public/javascripts/axios.js
index cf8b39db..9f42a7ae 100644
--- a/express-server/public/javascripts/axios.js
+++ b/express-server/public/javascripts/axios.js
@@ -1,1603 +1,1681 @@
/* axios v0.18.0 | (c) 2018 by Matt Zabriskie */
(function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
+ if (typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
- else if(typeof define === 'function' && define.amd)
+ else if (typeof define === 'function' && define.amd)
define([], factory);
- else if(typeof exports === 'object')
+ else if (typeof exports === 'object')
exports["axios"] = factory();
else
root["axios"] = factory();
-})(this, function() {
-return /******/ (function(modules) { // webpackBootstrap
-/******/ // The module cache
-/******/ var installedModules = {};
-/******/
-/******/ // The require function
-/******/ function __webpack_require__(moduleId) {
-/******/
-/******/ // Check if module is in cache
-/******/ if(installedModules[moduleId])
-/******/ return installedModules[moduleId].exports;
-/******/
-/******/ // Create a new module (and put it into the cache)
-/******/ var module = installedModules[moduleId] = {
-/******/ exports: {},
-/******/ id: moduleId,
-/******/ loaded: false
-/******/ };
-/******/
-/******/ // Execute the module function
-/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
-/******/
-/******/ // Flag the module as loaded
-/******/ module.loaded = true;
-/******/
-/******/ // Return the exports of the module
-/******/ return module.exports;
-/******/ }
-/******/
-/******/
-/******/ // expose the modules object (__webpack_modules__)
-/******/ __webpack_require__.m = modules;
-/******/
-/******/ // expose the module cache
-/******/ __webpack_require__.c = installedModules;
-/******/
-/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "";
-/******/
-/******/ // Load entry module and return exports
-/******/ return __webpack_require__(0);
-/******/ })
-/************************************************************************/
-/******/ ([
-/* 0 */
-/***/ (function(module, exports, __webpack_require__) {
-
- module.exports = __webpack_require__(1);
-
-/***/ }),
-/* 1 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var utils = __webpack_require__(2);
- var bind = __webpack_require__(3);
- var Axios = __webpack_require__(5);
- var defaults = __webpack_require__(6);
-
- /**
- * Create an instance of Axios
- *
- * @param {Object} defaultConfig The default config for the instance
- * @return {Axios} A new instance of Axios
- */
- function createInstance(defaultConfig) {
- var context = new Axios(defaultConfig);
- var instance = bind(Axios.prototype.request, context);
-
- // Copy axios.prototype to instance
- utils.extend(instance, Axios.prototype, context);
-
- // Copy context to instance
- utils.extend(instance, context);
-
- return instance;
- }
-
- // Create the default instance to be exported
- var axios = createInstance(defaults);
-
- // Expose Axios class to allow class inheritance
- axios.Axios = Axios;
-
- // Factory for creating new instances
- axios.create = function create(instanceConfig) {
- return createInstance(utils.merge(defaults, instanceConfig));
- };
-
- // Expose Cancel & CancelToken
- axios.Cancel = __webpack_require__(23);
- axios.CancelToken = __webpack_require__(24);
- axios.isCancel = __webpack_require__(20);
-
- // Expose all/spread
- axios.all = function all(promises) {
- return Promise.all(promises);
- };
- axios.spread = __webpack_require__(25);
-
- module.exports = axios;
-
- // Allow use of default import syntax in TypeScript
- module.exports.default = axios;
-
-
-/***/ }),
-/* 2 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var bind = __webpack_require__(3);
- var isBuffer = __webpack_require__(4);
-
- /*global toString:true*/
-
- // utils is a library of generic helper functions non-specific to axios
-
- var toString = Object.prototype.toString;
-
- /**
- * Determine if a value is an Array
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an Array, otherwise false
- */
- function isArray(val) {
- return toString.call(val) === '[object Array]';
- }
-
- /**
- * Determine if a value is an ArrayBuffer
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an ArrayBuffer, otherwise false
- */
- function isArrayBuffer(val) {
- return toString.call(val) === '[object ArrayBuffer]';
- }
-
- /**
- * Determine if a value is a FormData
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an FormData, otherwise false
- */
- function isFormData(val) {
- return (typeof FormData !== 'undefined') && (val instanceof FormData);
- }
-
- /**
- * Determine if a value is a view on an ArrayBuffer
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
- */
- function isArrayBufferView(val) {
- var result;
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
- result = ArrayBuffer.isView(val);
- } else {
- result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
- }
- return result;
- }
-
- /**
- * Determine if a value is a String
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a String, otherwise false
- */
- function isString(val) {
- return typeof val === 'string';
- }
-
- /**
- * Determine if a value is a Number
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Number, otherwise false
- */
- function isNumber(val) {
- return typeof val === 'number';
- }
-
- /**
- * Determine if a value is undefined
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if the value is undefined, otherwise false
- */
- function isUndefined(val) {
- return typeof val === 'undefined';
- }
-
- /**
- * Determine if a value is an Object
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is an Object, otherwise false
- */
- function isObject(val) {
- return val !== null && typeof val === 'object';
- }
-
- /**
- * Determine if a value is a Date
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Date, otherwise false
- */
- function isDate(val) {
- return toString.call(val) === '[object Date]';
- }
-
- /**
- * Determine if a value is a File
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a File, otherwise false
- */
- function isFile(val) {
- return toString.call(val) === '[object File]';
- }
-
- /**
- * Determine if a value is a Blob
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Blob, otherwise false
- */
- function isBlob(val) {
- return toString.call(val) === '[object Blob]';
- }
-
- /**
- * Determine if a value is a Function
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Function, otherwise false
- */
- function isFunction(val) {
- return toString.call(val) === '[object Function]';
- }
-
- /**
- * Determine if a value is a Stream
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a Stream, otherwise false
- */
- function isStream(val) {
- return isObject(val) && isFunction(val.pipe);
- }
-
- /**
- * Determine if a value is a URLSearchParams object
- *
- * @param {Object} val The value to test
- * @returns {boolean} True if value is a URLSearchParams object, otherwise false
- */
- function isURLSearchParams(val) {
- return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
- }
-
- /**
- * Trim excess whitespace off the beginning and end of a string
- *
- * @param {String} str The String to trim
- * @returns {String} The String freed of excess whitespace
- */
- function trim(str) {
- return str.replace(/^\s*/, '').replace(/\s*$/, '');
- }
-
- /**
- * Determine if we're running in a standard browser environment
- *
- * This allows axios to run in a web worker, and react-native.
- * Both environments support XMLHttpRequest, but not fully standard globals.
- *
- * web workers:
- * typeof window -> undefined
- * typeof document -> undefined
- *
- * react-native:
- * navigator.product -> 'ReactNative'
- */
- function isStandardBrowserEnv() {
- if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
- return false;
- }
- return (
- typeof window !== 'undefined' &&
- typeof document !== 'undefined'
- );
- }
-
- /**
- * Iterate over an Array or an Object invoking a function for each item.
- *
- * If `obj` is an Array callback will be called passing
- * the value, index, and complete array for each item.
- *
- * If 'obj' is an Object callback will be called passing
- * the value, key, and complete object for each property.
- *
- * @param {Object|Array} obj The object to iterate
- * @param {Function} fn The callback to invoke for each item
- */
- function forEach(obj, fn) {
- // Don't bother if no value provided
- if (obj === null || typeof obj === 'undefined') {
- return;
- }
-
- // Force an array if not already something iterable
- if (typeof obj !== 'object') {
- /*eslint no-param-reassign:0*/
- obj = [obj];
- }
-
- if (isArray(obj)) {
- // Iterate over array values
- for (var i = 0, l = obj.length; i < l; i++) {
- fn.call(null, obj[i], i, obj);
- }
- } else {
- // Iterate over object keys
- for (var key in obj) {
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
- fn.call(null, obj[key], key, obj);
- }
- }
- }
- }
-
- /**
- * Accepts varargs expecting each argument to be an object, then
- * immutably merges the properties of each object and returns result.
- *
- * When multiple objects contain the same key the later object in
- * the arguments list will take precedence.
- *
- * Example:
- *
- * ```js
- * var result = merge({foo: 123}, {foo: 456});
- * console.log(result.foo); // outputs 456
- * ```
- *
- * @param {Object} obj1 Object to merge
- * @returns {Object} Result of all merge properties
- */
- function merge(/* obj1, obj2, obj3, ... */) {
- var result = {};
- function assignValue(val, key) {
- if (typeof result[key] === 'object' && typeof val === 'object') {
- result[key] = merge(result[key], val);
- } else {
- result[key] = val;
- }
- }
-
- for (var i = 0, l = arguments.length; i < l; i++) {
- forEach(arguments[i], assignValue);
- }
- return result;
- }
-
- /**
- * Extends object a by mutably adding to it the properties of object b.
- *
- * @param {Object} a The object to be extended
- * @param {Object} b The object to copy properties from
- * @param {Object} thisArg The object to bind function to
- * @return {Object} The resulting value of object a
- */
- function extend(a, b, thisArg) {
- forEach(b, function assignValue(val, key) {
- if (thisArg && typeof val === 'function') {
- a[key] = bind(val, thisArg);
- } else {
- a[key] = val;
- }
- });
- return a;
- }
-
- module.exports = {
- isArray: isArray,
- isArrayBuffer: isArrayBuffer,
- isBuffer: isBuffer,
- isFormData: isFormData,
- isArrayBufferView: isArrayBufferView,
- isString: isString,
- isNumber: isNumber,
- isObject: isObject,
- isUndefined: isUndefined,
- isDate: isDate,
- isFile: isFile,
- isBlob: isBlob,
- isFunction: isFunction,
- isStream: isStream,
- isURLSearchParams: isURLSearchParams,
- isStandardBrowserEnv: isStandardBrowserEnv,
- forEach: forEach,
- merge: merge,
- extend: extend,
- trim: trim
- };
-
-
-/***/ }),
-/* 3 */
-/***/ (function(module, exports) {
-
- 'use strict';
-
- module.exports = function bind(fn, thisArg) {
- return function wrap() {
- var args = new Array(arguments.length);
- for (var i = 0; i < args.length; i++) {
- args[i] = arguments[i];
- }
- return fn.apply(thisArg, args);
- };
- };
-
-
-/***/ }),
-/* 4 */
-/***/ (function(module, exports) {
-
- /*!
- * Determine if an object is a Buffer
- *
- * @author Feross Aboukhadijeh
- * @license MIT
- */
-
- // The _isBuffer check is for Safari 5-7 support, because it's missing
- // Object.prototype.constructor. Remove this eventually
- module.exports = function (obj) {
- return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
- }
-
- function isBuffer (obj) {
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
- }
-
- // For Node v0.10 support. Remove this eventually.
- function isSlowBuffer (obj) {
- return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
- }
-
-
-/***/ }),
-/* 5 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var defaults = __webpack_require__(6);
- var utils = __webpack_require__(2);
- var InterceptorManager = __webpack_require__(17);
- var dispatchRequest = __webpack_require__(18);
-
- /**
- * Create a new instance of Axios
- *
- * @param {Object} instanceConfig The default config for the instance
- */
- function Axios(instanceConfig) {
- this.defaults = instanceConfig;
- this.interceptors = {
- request: new InterceptorManager(),
- response: new InterceptorManager()
- };
- }
-
- /**
- * Dispatch a request
- *
- * @param {Object} config The config specific for this request (merged with this.defaults)
- */
- Axios.prototype.request = function request(config) {
- /*eslint no-param-reassign:0*/
- // Allow for axios('example/url'[, config]) a la fetch API
- if (typeof config === 'string') {
- config = utils.merge({
- url: arguments[0]
- }, arguments[1]);
- }
-
- config = utils.merge(defaults, {method: 'get'}, this.defaults, config);
- config.method = config.method.toLowerCase();
-
- // Hook up interceptors middleware
- var chain = [dispatchRequest, undefined];
- var promise = Promise.resolve(config);
-
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
- chain.unshift(interceptor.fulfilled, interceptor.rejected);
- });
-
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
- chain.push(interceptor.fulfilled, interceptor.rejected);
- });
-
- while (chain.length) {
- promise = promise.then(chain.shift(), chain.shift());
- }
-
- return promise;
- };
-
- // Provide aliases for supported request methods
- utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
- /*eslint func-names:0*/
- Axios.prototype[method] = function(url, config) {
- return this.request(utils.merge(config || {}, {
- method: method,
- url: url
- }));
- };
- });
-
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
- /*eslint func-names:0*/
- Axios.prototype[method] = function(url, data, config) {
- return this.request(utils.merge(config || {}, {
- method: method,
- url: url,
- data: data
- }));
- };
- });
-
- module.exports = Axios;
-
-
-/***/ }),
-/* 6 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var utils = __webpack_require__(2);
- var normalizeHeaderName = __webpack_require__(7);
-
- var DEFAULT_CONTENT_TYPE = {
- 'Content-Type': 'application/x-www-form-urlencoded'
- };
-
- function setContentTypeIfUnset(headers, value) {
- if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
- headers['Content-Type'] = value;
- }
- }
-
- function getDefaultAdapter() {
- var adapter;
- if (typeof XMLHttpRequest !== 'undefined') {
- // For browsers use XHR adapter
- adapter = __webpack_require__(8);
- } else if (typeof process !== 'undefined') {
- // For node use HTTP adapter
- adapter = __webpack_require__(8);
- }
- return adapter;
- }
-
- var defaults = {
- adapter: getDefaultAdapter(),
-
- transformRequest: [function transformRequest(data, headers) {
- normalizeHeaderName(headers, 'Content-Type');
- if (utils.isFormData(data) ||
- utils.isArrayBuffer(data) ||
- utils.isBuffer(data) ||
- utils.isStream(data) ||
- utils.isFile(data) ||
- utils.isBlob(data)
- ) {
- return data;
- }
- if (utils.isArrayBufferView(data)) {
- return data.buffer;
- }
- if (utils.isURLSearchParams(data)) {
- setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
- return data.toString();
- }
- if (utils.isObject(data)) {
- setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
- return JSON.stringify(data);
- }
- return data;
- }],
-
- transformResponse: [function transformResponse(data) {
- /*eslint no-param-reassign:0*/
- if (typeof data === 'string') {
- try {
- data = JSON.parse(data);
- } catch (e) { /* Ignore */ }
- }
- return data;
- }],
-
- /**
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
- * timeout is not created.
- */
- timeout: 0,
-
- xsrfCookieName: 'XSRF-TOKEN',
- xsrfHeaderName: 'X-XSRF-TOKEN',
-
- maxContentLength: -1,
-
- validateStatus: function validateStatus(status) {
- return status >= 200 && status < 300;
- }
- };
-
- defaults.headers = {
- common: {
- 'Accept': 'application/json, text/plain, */*'
- }
- };
-
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
- defaults.headers[method] = {};
- });
-
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
- });
-
- module.exports = defaults;
-
-
-/***/ }),
-/* 7 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var utils = __webpack_require__(2);
-
- module.exports = function normalizeHeaderName(headers, normalizedName) {
- utils.forEach(headers, function processHeader(value, name) {
- if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
- headers[normalizedName] = value;
- delete headers[name];
- }
- });
- };
-
-
-/***/ }),
-/* 8 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var utils = __webpack_require__(2);
- var settle = __webpack_require__(9);
- var buildURL = __webpack_require__(12);
- var parseHeaders = __webpack_require__(13);
- var isURLSameOrigin = __webpack_require__(14);
- var createError = __webpack_require__(10);
- var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__(15);
-
- module.exports = function xhrAdapter(config) {
- return new Promise(function dispatchXhrRequest(resolve, reject) {
- var requestData = config.data;
- var requestHeaders = config.headers;
-
- if (utils.isFormData(requestData)) {
- delete requestHeaders['Content-Type']; // Let the browser set it
- }
-
- var request = new XMLHttpRequest();
- var loadEvent = 'onreadystatechange';
- var xDomain = false;
-
- // For IE 8/9 CORS support
- // Only supports POST and GET calls and doesn't returns the response headers.
- // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
- if (("production") !== 'test' &&
- typeof window !== 'undefined' &&
- window.XDomainRequest && !('withCredentials' in request) &&
- !isURLSameOrigin(config.url)) {
- request = new window.XDomainRequest();
- loadEvent = 'onload';
- xDomain = true;
- request.onprogress = function handleProgress() {};
- request.ontimeout = function handleTimeout() {};
- }
-
- // HTTP basic authentication
- if (config.auth) {
- var username = config.auth.username || '';
- var password = config.auth.password || '';
- requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
- }
-
- request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
-
- // Set the request timeout in MS
- request.timeout = config.timeout;
-
- // Listen for ready state
- request[loadEvent] = function handleLoad() {
- if (!request || (request.readyState !== 4 && !xDomain)) {
- return;
- }
-
- // The request errored out and we didn't get a response, this will be
- // handled by onerror instead
- // With one exception: request that using file: protocol, most browsers
- // will return status as 0 even though it's a successful request
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
- return;
- }
-
- // Prepare the response
- var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
- var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
- var response = {
- data: responseData,
- // IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201)
- status: request.status === 1223 ? 204 : request.status,
- statusText: request.status === 1223 ? 'No Content' : request.statusText,
- headers: responseHeaders,
- config: config,
- request: request
- };
-
- settle(resolve, reject, response);
-
- // Clean up request
- request = null;
- };
-
- // Handle low level network errors
- request.onerror = function handleError() {
- // Real errors are hidden from us by the browser
- // onerror should only fire if it's a network error
- reject(createError('Network Error', config, null, request));
-
- // Clean up request
- request = null;
- };
-
- // Handle timeout
- request.ontimeout = function handleTimeout() {
- reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',
- request));
-
- // Clean up request
- request = null;
- };
-
- // Add xsrf header
- // This is only done if running in a standard browser environment.
- // Specifically not if we're in a web worker, or react-native.
- if (utils.isStandardBrowserEnv()) {
- var cookies = __webpack_require__(16);
-
- // Add xsrf header
- var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
- cookies.read(config.xsrfCookieName) :
- undefined;
-
- if (xsrfValue) {
- requestHeaders[config.xsrfHeaderName] = xsrfValue;
- }
- }
-
- // Add headers to the request
- if ('setRequestHeader' in request) {
- utils.forEach(requestHeaders, function setRequestHeader(val, key) {
- if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
- // Remove Content-Type if data is undefined
- delete requestHeaders[key];
- } else {
- // Otherwise add header to the request
- request.setRequestHeader(key, val);
- }
- });
- }
-
- // Add withCredentials to request if needed
- if (config.withCredentials) {
- request.withCredentials = true;
- }
-
- // Add responseType to request if needed
- if (config.responseType) {
- try {
- request.responseType = config.responseType;
- } catch (e) {
- // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
- // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
- if (config.responseType !== 'json') {
- throw e;
- }
- }
- }
-
- // Handle progress if needed
- if (typeof config.onDownloadProgress === 'function') {
- request.addEventListener('progress', config.onDownloadProgress);
- }
-
- // Not all browsers support upload events
- if (typeof config.onUploadProgress === 'function' && request.upload) {
- request.upload.addEventListener('progress', config.onUploadProgress);
- }
-
- if (config.cancelToken) {
- // Handle cancellation
- config.cancelToken.promise.then(function onCanceled(cancel) {
- if (!request) {
- return;
- }
-
- request.abort();
- reject(cancel);
- // Clean up request
- request = null;
- });
- }
-
- if (requestData === undefined) {
- requestData = null;
- }
-
- // Send the request
- request.send(requestData);
- });
- };
-
-
-/***/ }),
-/* 9 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var createError = __webpack_require__(10);
-
- /**
- * Resolve or reject a Promise based on response status.
- *
- * @param {Function} resolve A function that resolves the promise.
- * @param {Function} reject A function that rejects the promise.
- * @param {object} response The response.
- */
- module.exports = function settle(resolve, reject, response) {
- var validateStatus = response.config.validateStatus;
- // Note: status is not exposed by XDomainRequest
- if (!response.status || !validateStatus || validateStatus(response.status)) {
- resolve(response);
- } else {
- reject(createError(
- 'Request failed with status code ' + response.status,
- response.config,
- null,
- response.request,
- response
- ));
- }
- };
-
-
-/***/ }),
-/* 10 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var enhanceError = __webpack_require__(11);
-
- /**
- * Create an Error with the specified message, config, error code, request and response.
- *
- * @param {string} message The error message.
- * @param {Object} config The config.
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
- * @param {Object} [request] The request.
- * @param {Object} [response] The response.
- * @returns {Error} The created error.
- */
- module.exports = function createError(message, config, code, request, response) {
- var error = new Error(message);
- return enhanceError(error, config, code, request, response);
- };
-
-
-/***/ }),
-/* 11 */
-/***/ (function(module, exports) {
-
- 'use strict';
-
- /**
- * Update an Error with the specified config, error code, and response.
- *
- * @param {Error} error The error to update.
- * @param {Object} config The config.
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
- * @param {Object} [request] The request.
- * @param {Object} [response] The response.
- * @returns {Error} The error.
- */
- module.exports = function enhanceError(error, config, code, request, response) {
- error.config = config;
- if (code) {
- error.code = code;
- }
- error.request = request;
- error.response = response;
- return error;
- };
-
-
-/***/ }),
-/* 12 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var utils = __webpack_require__(2);
-
- function encode(val) {
- return encodeURIComponent(val).
- replace(/%40/gi, '@').
- replace(/%3A/gi, ':').
- replace(/%24/g, '$').
- replace(/%2C/gi, ',').
- replace(/%20/g, '+').
- replace(/%5B/gi, '[').
- replace(/%5D/gi, ']');
- }
-
- /**
- * Build a URL by appending params to the end
- *
- * @param {string} url The base of the url (e.g., http://www.google.com)
- * @param {object} [params] The params to be appended
- * @returns {string} The formatted url
- */
- module.exports = function buildURL(url, params, paramsSerializer) {
- /*eslint no-param-reassign:0*/
- if (!params) {
- return url;
- }
-
- var serializedParams;
- if (paramsSerializer) {
- serializedParams = paramsSerializer(params);
- } else if (utils.isURLSearchParams(params)) {
- serializedParams = params.toString();
- } else {
- var parts = [];
-
- utils.forEach(params, function serialize(val, key) {
- if (val === null || typeof val === 'undefined') {
- return;
- }
-
- if (utils.isArray(val)) {
- key = key + '[]';
- } else {
- val = [val];
- }
-
- utils.forEach(val, function parseValue(v) {
- if (utils.isDate(v)) {
- v = v.toISOString();
- } else if (utils.isObject(v)) {
- v = JSON.stringify(v);
- }
- parts.push(encode(key) + '=' + encode(v));
- });
- });
-
- serializedParams = parts.join('&');
- }
-
- if (serializedParams) {
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
- }
-
- return url;
- };
-
-
-/***/ }),
-/* 13 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var utils = __webpack_require__(2);
-
- // Headers whose duplicates are ignored by node
- // c.f. https://nodejs.org/api/http.html#http_message_headers
- var ignoreDuplicateOf = [
- 'age', 'authorization', 'content-length', 'content-type', 'etag',
- 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
- 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
- 'referer', 'retry-after', 'user-agent'
- ];
-
- /**
- * Parse headers into an object
- *
- * ```
- * Date: Wed, 27 Aug 2014 08:58:49 GMT
- * Content-Type: application/json
- * Connection: keep-alive
- * Transfer-Encoding: chunked
- * ```
- *
- * @param {String} headers Headers needing to be parsed
- * @returns {Object} Headers parsed into an object
- */
- module.exports = function parseHeaders(headers) {
- var parsed = {};
- var key;
- var val;
- var i;
-
- if (!headers) { return parsed; }
-
- utils.forEach(headers.split('\n'), function parser(line) {
- i = line.indexOf(':');
- key = utils.trim(line.substr(0, i)).toLowerCase();
- val = utils.trim(line.substr(i + 1));
-
- if (key) {
- if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
- return;
- }
- if (key === 'set-cookie') {
- parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
- } else {
- parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
- }
- }
- });
-
- return parsed;
- };
-
-
-/***/ }),
-/* 14 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var utils = __webpack_require__(2);
-
- module.exports = (
- utils.isStandardBrowserEnv() ?
-
- // Standard browser envs have full support of the APIs needed to test
- // whether the request URL is of the same origin as current location.
- (function standardBrowserEnv() {
- var msie = /(msie|trident)/i.test(navigator.userAgent);
- var urlParsingNode = document.createElement('a');
- var originURL;
-
- /**
- * Parse a URL to discover it's components
- *
- * @param {String} url The URL to be parsed
- * @returns {Object}
- */
- function resolveURL(url) {
- var href = url;
-
- if (msie) {
- // IE needs attribute set twice to normalize properties
- urlParsingNode.setAttribute('href', href);
- href = urlParsingNode.href;
- }
-
- urlParsingNode.setAttribute('href', href);
-
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
- return {
- href: urlParsingNode.href,
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
- host: urlParsingNode.host,
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
- hostname: urlParsingNode.hostname,
- port: urlParsingNode.port,
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
- urlParsingNode.pathname :
- '/' + urlParsingNode.pathname
- };
- }
-
- originURL = resolveURL(window.location.href);
-
- /**
- * Determine if a URL shares the same origin as the current location
- *
- * @param {String} requestURL The URL to test
- * @returns {boolean} True if URL shares the same origin, otherwise false
- */
- return function isURLSameOrigin(requestURL) {
- var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
- return (parsed.protocol === originURL.protocol &&
- parsed.host === originURL.host);
- };
- })() :
-
- // Non standard browser envs (web workers, react-native) lack needed support.
- (function nonStandardBrowserEnv() {
- return function isURLSameOrigin() {
- return true;
- };
- })()
- );
-
-
-/***/ }),
-/* 15 */
-/***/ (function(module, exports) {
-
- 'use strict';
-
- // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
-
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
-
- function E() {
- this.message = 'String contains an invalid character';
- }
- E.prototype = new Error;
- E.prototype.code = 5;
- E.prototype.name = 'InvalidCharacterError';
-
- function btoa(input) {
- var str = String(input);
- var output = '';
- for (
- // initialize result and counter
- var block, charCode, idx = 0, map = chars;
- // if the next str index does not exist:
- // change the mapping table to "="
- // check if d has no fractional digits
- str.charAt(idx | 0) || (map = '=', idx % 1);
- // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
- output += map.charAt(63 & block >> 8 - idx % 1 * 8)
- ) {
- charCode = str.charCodeAt(idx += 3 / 4);
- if (charCode > 0xFF) {
- throw new E();
- }
- block = block << 8 | charCode;
- }
- return output;
- }
-
- module.exports = btoa;
-
-
-/***/ }),
-/* 16 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var utils = __webpack_require__(2);
-
- module.exports = (
- utils.isStandardBrowserEnv() ?
-
- // Standard browser envs support document.cookie
- (function standardBrowserEnv() {
- return {
- write: function write(name, value, expires, path, domain, secure) {
- var cookie = [];
- cookie.push(name + '=' + encodeURIComponent(value));
-
- if (utils.isNumber(expires)) {
- cookie.push('expires=' + new Date(expires).toGMTString());
- }
-
- if (utils.isString(path)) {
- cookie.push('path=' + path);
- }
-
- if (utils.isString(domain)) {
- cookie.push('domain=' + domain);
- }
-
- if (secure === true) {
- cookie.push('secure');
- }
-
- document.cookie = cookie.join('; ');
- },
-
- read: function read(name) {
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
- return (match ? decodeURIComponent(match[3]) : null);
- },
-
- remove: function remove(name) {
- this.write(name, '', Date.now() - 86400000);
- }
- };
- })() :
-
- // Non standard browser env (web workers, react-native) lack needed support.
- (function nonStandardBrowserEnv() {
- return {
- write: function write() {},
- read: function read() { return null; },
- remove: function remove() {}
- };
- })()
- );
-
-
-/***/ }),
-/* 17 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var utils = __webpack_require__(2);
-
- function InterceptorManager() {
- this.handlers = [];
- }
-
- /**
- * Add a new interceptor to the stack
- *
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
- * @param {Function} rejected The function to handle `reject` for a `Promise`
- *
- * @return {Number} An ID used to remove interceptor later
- */
- InterceptorManager.prototype.use = function use(fulfilled, rejected) {
- this.handlers.push({
- fulfilled: fulfilled,
- rejected: rejected
- });
- return this.handlers.length - 1;
- };
-
- /**
- * Remove an interceptor from the stack
- *
- * @param {Number} id The ID that was returned by `use`
- */
- InterceptorManager.prototype.eject = function eject(id) {
- if (this.handlers[id]) {
- this.handlers[id] = null;
- }
- };
-
- /**
- * Iterate over all the registered interceptors
- *
- * This method is particularly useful for skipping over any
- * interceptors that may have become `null` calling `eject`.
- *
- * @param {Function} fn The function to call for each interceptor
- */
- InterceptorManager.prototype.forEach = function forEach(fn) {
- utils.forEach(this.handlers, function forEachHandler(h) {
- if (h !== null) {
- fn(h);
- }
- });
- };
-
- module.exports = InterceptorManager;
-
-
-/***/ }),
-/* 18 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var utils = __webpack_require__(2);
- var transformData = __webpack_require__(19);
- var isCancel = __webpack_require__(20);
- var defaults = __webpack_require__(6);
- var isAbsoluteURL = __webpack_require__(21);
- var combineURLs = __webpack_require__(22);
-
- /**
- * Throws a `Cancel` if cancellation has been requested.
- */
- function throwIfCancellationRequested(config) {
- if (config.cancelToken) {
- config.cancelToken.throwIfRequested();
- }
- }
-
- /**
- * Dispatch a request to the server using the configured adapter.
- *
- * @param {object} config The config that is to be used for the request
- * @returns {Promise} The Promise to be fulfilled
- */
- module.exports = function dispatchRequest(config) {
- throwIfCancellationRequested(config);
-
- // Support baseURL config
- if (config.baseURL && !isAbsoluteURL(config.url)) {
- config.url = combineURLs(config.baseURL, config.url);
- }
-
- // Ensure headers exist
- config.headers = config.headers || {};
-
- // Transform request data
- config.data = transformData(
- config.data,
- config.headers,
- config.transformRequest
- );
-
- // Flatten headers
- config.headers = utils.merge(
- config.headers.common || {},
- config.headers[config.method] || {},
- config.headers || {}
- );
-
- utils.forEach(
- ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
- function cleanHeaderConfig(method) {
- delete config.headers[method];
- }
- );
-
- var adapter = config.adapter || defaults.adapter;
-
- return adapter(config).then(function onAdapterResolution(response) {
- throwIfCancellationRequested(config);
-
- // Transform response data
- response.data = transformData(
- response.data,
- response.headers,
- config.transformResponse
- );
-
- return response;
- }, function onAdapterRejection(reason) {
- if (!isCancel(reason)) {
- throwIfCancellationRequested(config);
-
- // Transform response data
- if (reason && reason.response) {
- reason.response.data = transformData(
- reason.response.data,
- reason.response.headers,
- config.transformResponse
- );
- }
- }
-
- return Promise.reject(reason);
- });
- };
-
-
-/***/ }),
-/* 19 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var utils = __webpack_require__(2);
-
- /**
- * Transform the data for a request or a response
- *
- * @param {Object|String} data The data to be transformed
- * @param {Array} headers The headers for the request or response
- * @param {Array|Function} fns A single function or Array of functions
- * @returns {*} The resulting transformed data
- */
- module.exports = function transformData(data, headers, fns) {
- /*eslint no-param-reassign:0*/
- utils.forEach(fns, function transform(fn) {
- data = fn(data, headers);
- });
-
- return data;
- };
-
-
-/***/ }),
-/* 20 */
-/***/ (function(module, exports) {
-
- 'use strict';
-
- module.exports = function isCancel(value) {
- return !!(value && value.__CANCEL__);
- };
-
-
-/***/ }),
-/* 21 */
-/***/ (function(module, exports) {
-
- 'use strict';
-
- /**
- * Determines whether the specified URL is absolute
- *
- * @param {string} url The URL to test
- * @returns {boolean} True if the specified URL is absolute, otherwise false
- */
- module.exports = function isAbsoluteURL(url) {
- // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL).
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
- // by any combination of letters, digits, plus, period, or hyphen.
- return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
- };
-
-
-/***/ }),
-/* 22 */
-/***/ (function(module, exports) {
-
- 'use strict';
-
- /**
- * Creates a new URL by combining the specified URLs
- *
- * @param {string} baseURL The base URL
- * @param {string} relativeURL The relative URL
- * @returns {string} The combined URL
- */
- module.exports = function combineURLs(baseURL, relativeURL) {
- return relativeURL
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
- : baseURL;
- };
-
-
-/***/ }),
-/* 23 */
-/***/ (function(module, exports) {
-
- 'use strict';
-
- /**
- * A `Cancel` is an object that is thrown when an operation is canceled.
- *
- * @class
- * @param {string=} message The message.
- */
- function Cancel(message) {
- this.message = message;
- }
-
- Cancel.prototype.toString = function toString() {
- return 'Cancel' + (this.message ? ': ' + this.message : '');
- };
-
- Cancel.prototype.__CANCEL__ = true;
-
- module.exports = Cancel;
-
-
-/***/ }),
-/* 24 */
-/***/ (function(module, exports, __webpack_require__) {
-
- 'use strict';
-
- var Cancel = __webpack_require__(23);
-
- /**
- * A `CancelToken` is an object that can be used to request cancellation of an operation.
- *
- * @class
- * @param {Function} executor The executor function.
- */
- function CancelToken(executor) {
- if (typeof executor !== 'function') {
- throw new TypeError('executor must be a function.');
- }
-
- var resolvePromise;
- this.promise = new Promise(function promiseExecutor(resolve) {
- resolvePromise = resolve;
- });
-
- var token = this;
- executor(function cancel(message) {
- if (token.reason) {
- // Cancellation has already been requested
- return;
- }
-
- token.reason = new Cancel(message);
- resolvePromise(token.reason);
- });
- }
-
- /**
- * Throws a `Cancel` if cancellation has been requested.
- */
- CancelToken.prototype.throwIfRequested = function throwIfRequested() {
- if (this.reason) {
- throw this.reason;
- }
- };
-
- /**
- * Returns an object that contains a new `CancelToken` and a function that, when called,
- * cancels the `CancelToken`.
- */
- CancelToken.source = function source() {
- var cancel;
- var token = new CancelToken(function executor(c) {
- cancel = c;
- });
- return {
- token: token,
- cancel: cancel
- };
- };
-
- module.exports = CancelToken;
-
-
-/***/ }),
-/* 25 */
-/***/ (function(module, exports) {
-
- 'use strict';
-
- /**
- * Syntactic sugar for invoking a function and expanding an array for arguments.
- *
- * Common use case would be to use `Function.prototype.apply`.
- *
- * ```js
- * function f(x, y, z) {}
- * var args = [1, 2, 3];
- * f.apply(null, args);
- * ```
- *
- * With `spread` this example can be re-written.
- *
- * ```js
- * spread(function(x, y, z) {})([1, 2, 3]);
- * ```
- *
- * @param {Function} callback
- * @returns {Function}
- */
- module.exports = function spread(callback) {
- return function wrap(arr) {
- return callback.apply(null, arr);
- };
- };
-
-
-/***/ })
-/******/ ])
-});
-;
+})(this, function () {
+ return /******/ (function (modules) { // webpackBootstrap
+ /******/ // The module cache
+ /******/
+ var installedModules = {};
+ /******/
+ /******/ // The require function
+ /******/
+ function __webpack_require__(moduleId) {
+ /******/
+ /******/ // Check if module is in cache
+ /******/
+ if (installedModules[moduleId])
+ /******/
+ return installedModules[moduleId].exports;
+ /******/
+ /******/ // Create a new module (and put it into the cache)
+ /******/
+ var module = installedModules[moduleId] = {
+ /******/
+ exports: {},
+ /******/
+ id: moduleId,
+ /******/
+ loaded: false
+ /******/
+ };
+ /******/
+ /******/ // Execute the module function
+ /******/
+ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+ /******/
+ /******/ // Flag the module as loaded
+ /******/
+ module.loaded = true;
+ /******/
+ /******/ // Return the exports of the module
+ /******/
+ return module.exports;
+ /******/
+ }
+ /******/
+ /******/
+ /******/ // expose the modules object (__webpack_modules__)
+ /******/
+ __webpack_require__.m = modules;
+ /******/
+ /******/ // expose the module cache
+ /******/
+ __webpack_require__.c = installedModules;
+ /******/
+ /******/ // __webpack_public_path__
+ /******/
+ __webpack_require__.p = "";
+ /******/
+ /******/ // Load entry module and return exports
+ /******/
+ return __webpack_require__(0);
+ /******/
+ })
+ /************************************************************************/
+ /******/
+ ([
+ /* 0 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ module.exports = __webpack_require__(1);
+
+ /***/
+ }),
+ /* 1 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var utils = __webpack_require__(2);
+ var bind = __webpack_require__(3);
+ var Axios = __webpack_require__(5);
+ var defaults = __webpack_require__(6);
+
+ /**
+ * Create an instance of Axios
+ *
+ * @param {Object} defaultConfig The default config for the instance
+ * @return {Axios} A new instance of Axios
+ */
+ function createInstance(defaultConfig) {
+ var context = new Axios(defaultConfig);
+ var instance = bind(Axios.prototype.request, context);
+
+ // Copy axios.prototype to instance
+ utils.extend(instance, Axios.prototype, context);
+
+ // Copy context to instance
+ utils.extend(instance, context);
+
+ return instance;
+ }
+
+ // Create the default instance to be exported
+ var axios = createInstance(defaults);
+
+ // Expose Axios class to allow class inheritance
+ axios.Axios = Axios;
+
+ // Factory for creating new instances
+ axios.create = function create(instanceConfig) {
+ return createInstance(utils.merge(defaults, instanceConfig));
+ };
+
+ // Expose Cancel & CancelToken
+ axios.Cancel = __webpack_require__(23);
+ axios.CancelToken = __webpack_require__(24);
+ axios.isCancel = __webpack_require__(20);
+
+ // Expose all/spread
+ axios.all = function all(promises) {
+ return Promise.all(promises);
+ };
+ axios.spread = __webpack_require__(25);
+
+ module.exports = axios;
+
+ // Allow use of default import syntax in TypeScript
+ module.exports.default = axios;
+
+
+ /***/
+ }),
+ /* 2 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var bind = __webpack_require__(3);
+ var isBuffer = __webpack_require__(4);
+
+ /*global toString:true*/
+
+ // utils is a library of generic helper functions non-specific to axios
+
+ var toString = Object.prototype.toString;
+
+ /**
+ * Determine if a value is an Array
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if value is an Array, otherwise false
+ */
+ function isArray(val) {
+ return toString.call(val) === '[object Array]';
+ }
+
+ /**
+ * Determine if a value is an ArrayBuffer
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
+ */
+ function isArrayBuffer(val) {
+ return toString.call(val) === '[object ArrayBuffer]';
+ }
+
+ /**
+ * Determine if a value is a FormData
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if value is an FormData, otherwise false
+ */
+ function isFormData(val) {
+ return (typeof FormData !== 'undefined') && (val instanceof FormData);
+ }
+
+ /**
+ * Determine if a value is a view on an ArrayBuffer
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
+ */
+ function isArrayBufferView(val) {
+ var result;
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
+ result = ArrayBuffer.isView(val);
+ } else {
+ result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
+ }
+ return result;
+ }
+
+ /**
+ * Determine if a value is a String
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if value is a String, otherwise false
+ */
+ function isString(val) {
+ return typeof val === 'string';
+ }
+
+ /**
+ * Determine if a value is a Number
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if value is a Number, otherwise false
+ */
+ function isNumber(val) {
+ return typeof val === 'number';
+ }
+
+ /**
+ * Determine if a value is undefined
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if the value is undefined, otherwise false
+ */
+ function isUndefined(val) {
+ return typeof val === 'undefined';
+ }
+
+ /**
+ * Determine if a value is an Object
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if value is an Object, otherwise false
+ */
+ function isObject(val) {
+ return val !== null && typeof val === 'object';
+ }
+
+ /**
+ * Determine if a value is a Date
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if value is a Date, otherwise false
+ */
+ function isDate(val) {
+ return toString.call(val) === '[object Date]';
+ }
+
+ /**
+ * Determine if a value is a File
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if value is a File, otherwise false
+ */
+ function isFile(val) {
+ return toString.call(val) === '[object File]';
+ }
+
+ /**
+ * Determine if a value is a Blob
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if value is a Blob, otherwise false
+ */
+ function isBlob(val) {
+ return toString.call(val) === '[object Blob]';
+ }
+
+ /**
+ * Determine if a value is a Function
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if value is a Function, otherwise false
+ */
+ function isFunction(val) {
+ return toString.call(val) === '[object Function]';
+ }
+
+ /**
+ * Determine if a value is a Stream
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if value is a Stream, otherwise false
+ */
+ function isStream(val) {
+ return isObject(val) && isFunction(val.pipe);
+ }
+
+ /**
+ * Determine if a value is a URLSearchParams object
+ *
+ * @param {Object} val The value to test
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
+ */
+ function isURLSearchParams(val) {
+ return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
+ }
+
+ /**
+ * Trim excess whitespace off the beginning and end of a string
+ *
+ * @param {String} str The String to trim
+ * @returns {String} The String freed of excess whitespace
+ */
+ function trim(str) {
+ return str.replace(/^\s*/, '').replace(/\s*$/, '');
+ }
+
+ /**
+ * Determine if we're running in a standard browser environment
+ *
+ * This allows axios to run in a web worker, and react-native.
+ * Both environments support XMLHttpRequest, but not fully standard globals.
+ *
+ * web workers:
+ * typeof window -> undefined
+ * typeof document -> undefined
+ *
+ * react-native:
+ * navigator.product -> 'ReactNative'
+ */
+ function isStandardBrowserEnv() {
+ if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
+ return false;
+ }
+ return (
+ typeof window !== 'undefined' &&
+ typeof document !== 'undefined'
+ );
+ }
+
+ /**
+ * Iterate over an Array or an Object invoking a function for each item.
+ *
+ * If `obj` is an Array callback will be called passing
+ * the value, index, and complete array for each item.
+ *
+ * If 'obj' is an Object callback will be called passing
+ * the value, key, and complete object for each property.
+ *
+ * @param {Object|Array} obj The object to iterate
+ * @param {Function} fn The callback to invoke for each item
+ */
+ function forEach(obj, fn) {
+ // Don't bother if no value provided
+ if (obj === null || typeof obj === 'undefined') {
+ return;
+ }
+
+ // Force an array if not already something iterable
+ if (typeof obj !== 'object') {
+ /*eslint no-param-reassign:0*/
+ obj = [obj];
+ }
+
+ if (isArray(obj)) {
+ // Iterate over array values
+ for (var i = 0, l = obj.length; i < l; i++) {
+ fn.call(null, obj[i], i, obj);
+ }
+ } else {
+ // Iterate over object keys
+ for (var key in obj) {
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
+ fn.call(null, obj[key], key, obj);
+ }
+ }
+ }
+ }
+
+ /**
+ * Accepts varargs expecting each argument to be an object, then
+ * immutably merges the properties of each object and returns result.
+ *
+ * When multiple objects contain the same key the later object in
+ * the arguments list will take precedence.
+ *
+ * Example:
+ *
+ * ```js
+ * var result = merge({foo: 123}, {foo: 456});
+ * console.log(result.foo); // outputs 456
+ * ```
+ *
+ * @param {Object} obj1 Object to merge
+ * @returns {Object} Result of all merge properties
+ */
+ function merge( /* obj1, obj2, obj3, ... */ ) {
+ var result = {};
+
+ function assignValue(val, key) {
+ if (typeof result[key] === 'object' && typeof val === 'object') {
+ result[key] = merge(result[key], val);
+ } else {
+ result[key] = val;
+ }
+ }
+
+ for (var i = 0, l = arguments.length; i < l; i++) {
+ forEach(arguments[i], assignValue);
+ }
+ return result;
+ }
+
+ /**
+ * Extends object a by mutably adding to it the properties of object b.
+ *
+ * @param {Object} a The object to be extended
+ * @param {Object} b The object to copy properties from
+ * @param {Object} thisArg The object to bind function to
+ * @return {Object} The resulting value of object a
+ */
+ function extend(a, b, thisArg) {
+ forEach(b, function assignValue(val, key) {
+ if (thisArg && typeof val === 'function') {
+ a[key] = bind(val, thisArg);
+ } else {
+ a[key] = val;
+ }
+ });
+ return a;
+ }
+
+ module.exports = {
+ isArray: isArray,
+ isArrayBuffer: isArrayBuffer,
+ isBuffer: isBuffer,
+ isFormData: isFormData,
+ isArrayBufferView: isArrayBufferView,
+ isString: isString,
+ isNumber: isNumber,
+ isObject: isObject,
+ isUndefined: isUndefined,
+ isDate: isDate,
+ isFile: isFile,
+ isBlob: isBlob,
+ isFunction: isFunction,
+ isStream: isStream,
+ isURLSearchParams: isURLSearchParams,
+ isStandardBrowserEnv: isStandardBrowserEnv,
+ forEach: forEach,
+ merge: merge,
+ extend: extend,
+ trim: trim
+ };
+
+
+ /***/
+ }),
+ /* 3 */
+ /***/
+ (function (module, exports) {
+
+ 'use strict';
+
+ module.exports = function bind(fn, thisArg) {
+ return function wrap() {
+ var args = new Array(arguments.length);
+ for (var i = 0; i < args.length; i++) {
+ args[i] = arguments[i];
+ }
+ return fn.apply(thisArg, args);
+ };
+ };
+
+
+ /***/
+ }),
+ /* 4 */
+ /***/
+ (function (module, exports) {
+
+ /*!
+ * Determine if an object is a Buffer
+ *
+ * @author Feross Aboukhadijeh
+ * @license MIT
+ */
+
+ // The _isBuffer check is for Safari 5-7 support, because it's missing
+ // Object.prototype.constructor. Remove this eventually
+ module.exports = function (obj) {
+ return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
+ }
+
+ function isBuffer(obj) {
+ return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
+ }
+
+ // For Node v0.10 support. Remove this eventually.
+ function isSlowBuffer(obj) {
+ return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
+ }
+
+
+ /***/
+ }),
+ /* 5 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var defaults = __webpack_require__(6);
+ var utils = __webpack_require__(2);
+ var InterceptorManager = __webpack_require__(17);
+ var dispatchRequest = __webpack_require__(18);
+
+ /**
+ * Create a new instance of Axios
+ *
+ * @param {Object} instanceConfig The default config for the instance
+ */
+ function Axios(instanceConfig) {
+ this.defaults = instanceConfig;
+ this.interceptors = {
+ request: new InterceptorManager(),
+ response: new InterceptorManager()
+ };
+ }
+
+ /**
+ * Dispatch a request
+ *
+ * @param {Object} config The config specific for this request (merged with this.defaults)
+ */
+ Axios.prototype.request = function request(config) {
+ /*eslint no-param-reassign:0*/
+ // Allow for axios('example/url'[, config]) a la fetch API
+ if (typeof config === 'string') {
+ config = utils.merge({
+ url: arguments[0]
+ }, arguments[1]);
+ }
+
+ config = utils.merge(defaults, {
+ method: 'get'
+ }, this.defaults, config);
+ config.method = config.method.toLowerCase();
+
+ // Hook up interceptors middleware
+ var chain = [dispatchRequest, undefined];
+ var promise = Promise.resolve(config);
+
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
+ chain.unshift(interceptor.fulfilled, interceptor.rejected);
+ });
+
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
+ chain.push(interceptor.fulfilled, interceptor.rejected);
+ });
+
+ while (chain.length) {
+ promise = promise.then(chain.shift(), chain.shift());
+ }
+
+ return promise;
+ };
+
+ // Provide aliases for supported request methods
+ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
+ /*eslint func-names:0*/
+ Axios.prototype[method] = function (url, config) {
+ return this.request(utils.merge(config || {}, {
+ method: method,
+ url: url
+ }));
+ };
+ });
+
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
+ /*eslint func-names:0*/
+ Axios.prototype[method] = function (url, data, config) {
+ return this.request(utils.merge(config || {}, {
+ method: method,
+ url: url,
+ data: data
+ }));
+ };
+ });
+
+ module.exports = Axios;
+
+
+ /***/
+ }),
+ /* 6 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var utils = __webpack_require__(2);
+ var normalizeHeaderName = __webpack_require__(7);
+
+ var DEFAULT_CONTENT_TYPE = {
+ 'Content-Type': 'application/x-www-form-urlencoded'
+ };
+
+ function setContentTypeIfUnset(headers, value) {
+ if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
+ headers['Content-Type'] = value;
+ }
+ }
+
+ function getDefaultAdapter() {
+ var adapter;
+ if (typeof XMLHttpRequest !== 'undefined') {
+ // For browsers use XHR adapter
+ adapter = __webpack_require__(8);
+ } else if (typeof process !== 'undefined') {
+ // For node use HTTP adapter
+ adapter = __webpack_require__(8);
+ }
+ return adapter;
+ }
+
+ var defaults = {
+ adapter: getDefaultAdapter(),
+
+ transformRequest: [function transformRequest(data, headers) {
+ normalizeHeaderName(headers, 'Content-Type');
+ if (utils.isFormData(data) ||
+ utils.isArrayBuffer(data) ||
+ utils.isBuffer(data) ||
+ utils.isStream(data) ||
+ utils.isFile(data) ||
+ utils.isBlob(data)
+ ) {
+ return data;
+ }
+ if (utils.isArrayBufferView(data)) {
+ return data.buffer;
+ }
+ if (utils.isURLSearchParams(data)) {
+ setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
+ return data.toString();
+ }
+ if (utils.isObject(data)) {
+ setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
+ return JSON.stringify(data);
+ }
+ return data;
+ }],
+
+ transformResponse: [function transformResponse(data) {
+ /*eslint no-param-reassign:0*/
+ if (typeof data === 'string') {
+ try {
+ data = JSON.parse(data);
+ } catch (e) {
+ /* Ignore */ }
+ }
+ return data;
+ }],
+
+ /**
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
+ * timeout is not created.
+ */
+ timeout: 0,
+
+ xsrfCookieName: 'XSRF-TOKEN',
+ xsrfHeaderName: 'X-XSRF-TOKEN',
+
+ maxContentLength: -1,
+
+ validateStatus: function validateStatus(status) {
+ return status >= 200 && status < 300;
+ }
+ };
+
+ defaults.headers = {
+ common: {
+ 'Accept': 'application/json, text/plain, */*'
+ }
+ };
+
+ utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
+ defaults.headers[method] = {};
+ });
+
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
+ defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
+ });
+
+ module.exports = defaults;
+
+
+ /***/
+ }),
+ /* 7 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var utils = __webpack_require__(2);
+
+ module.exports = function normalizeHeaderName(headers, normalizedName) {
+ utils.forEach(headers, function processHeader(value, name) {
+ if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
+ headers[normalizedName] = value;
+ delete headers[name];
+ }
+ });
+ };
+
+
+ /***/
+ }),
+ /* 8 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var utils = __webpack_require__(2);
+ var settle = __webpack_require__(9);
+ var buildURL = __webpack_require__(12);
+ var parseHeaders = __webpack_require__(13);
+ var isURLSameOrigin = __webpack_require__(14);
+ var createError = __webpack_require__(10);
+ var btoa = (typeof window !== 'undefined' && window.btoa && window.btoa.bind(window)) || __webpack_require__(15);
+
+ module.exports = function xhrAdapter(config) {
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
+ var requestData = config.data;
+ var requestHeaders = config.headers;
+
+ if (utils.isFormData(requestData)) {
+ delete requestHeaders['Content-Type']; // Let the browser set it
+ }
+
+ var request = new XMLHttpRequest();
+ var loadEvent = 'onreadystatechange';
+ var xDomain = false;
+
+ // For IE 8/9 CORS support
+ // Only supports POST and GET calls and doesn't returns the response headers.
+ // DON'T do this for testing b/c XMLHttpRequest is mocked, not XDomainRequest.
+ if (("production") !== 'test' &&
+ typeof window !== 'undefined' &&
+ window.XDomainRequest && !('withCredentials' in request) &&
+ !isURLSameOrigin(config.url)) {
+ request = new window.XDomainRequest();
+ loadEvent = 'onload';
+ xDomain = true;
+ request.onprogress = function handleProgress() {};
+ request.ontimeout = function handleTimeout() {};
+ }
+
+ // HTTP basic authentication
+ if (config.auth) {
+ var username = config.auth.username || '';
+ var password = config.auth.password || '';
+ requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
+ }
+
+ request.open(config.method.toUpperCase(), buildURL(config.url, config.params, config.paramsSerializer), true);
+
+ // Set the request timeout in MS
+ request.timeout = config.timeout;
+
+ // Listen for ready state
+ request[loadEvent] = function handleLoad() {
+ if (!request || (request.readyState !== 4 && !xDomain)) {
+ return;
+ }
+
+ // The request errored out and we didn't get a response, this will be
+ // handled by onerror instead
+ // With one exception: request that using file: protocol, most browsers
+ // will return status as 0 even though it's a successful request
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
+ return;
+ }
+
+ // Prepare the response
+ var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
+ var responseData = !config.responseType || config.responseType === 'text' ? request.responseText : request.response;
+ var response = {
+ data: responseData,
+ // IE sends 1223 instead of 204 (https://github.com/axios/axios/issues/201)
+ status: request.status === 1223 ? 204 : request.status,
+ statusText: request.status === 1223 ? 'No Content' : request.statusText,
+ headers: responseHeaders,
+ config: config,
+ request: request
+ };
+
+ settle(resolve, reject, response);
+
+ // Clean up request
+ request = null;
+ };
+
+ // Handle low level network errors
+ request.onerror = function handleError() {
+ // Real errors are hidden from us by the browser
+ // onerror should only fire if it's a network error
+ reject(createError('Network Error', config, null, request));
+
+ // Clean up request
+ request = null;
+ };
+
+ // Handle timeout
+ request.ontimeout = function handleTimeout() {
+ reject(createError('timeout of ' + config.timeout + 'ms exceeded', config, 'ECONNABORTED',
+ request));
+
+ // Clean up request
+ request = null;
+ };
+
+ // Add xsrf header
+ // This is only done if running in a standard browser environment.
+ // Specifically not if we're in a web worker, or react-native.
+ if (utils.isStandardBrowserEnv()) {
+ var cookies = __webpack_require__(16);
+
+ // Add xsrf header
+ var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
+ cookies.read(config.xsrfCookieName) :
+ undefined;
+
+ if (xsrfValue) {
+ requestHeaders[config.xsrfHeaderName] = xsrfValue;
+ }
+ }
+
+ // Add headers to the request
+ if ('setRequestHeader' in request) {
+ utils.forEach(requestHeaders, function setRequestHeader(val, key) {
+ if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
+ // Remove Content-Type if data is undefined
+ delete requestHeaders[key];
+ } else {
+ // Otherwise add header to the request
+ request.setRequestHeader(key, val);
+ }
+ });
+ }
+
+ // Add withCredentials to request if needed
+ if (config.withCredentials) {
+ request.withCredentials = true;
+ }
+
+ // Add responseType to request if needed
+ if (config.responseType) {
+ try {
+ request.responseType = config.responseType;
+ } catch (e) {
+ // Expected DOMException thrown by browsers not compatible XMLHttpRequest Level 2.
+ // But, this can be suppressed for 'json' type as it can be parsed by default 'transformResponse' function.
+ if (config.responseType !== 'json') {
+ throw e;
+ }
+ }
+ }
+
+ // Handle progress if needed
+ if (typeof config.onDownloadProgress === 'function') {
+ request.addEventListener('progress', config.onDownloadProgress);
+ }
+
+ // Not all browsers support upload events
+ if (typeof config.onUploadProgress === 'function' && request.upload) {
+ request.upload.addEventListener('progress', config.onUploadProgress);
+ }
+
+ if (config.cancelToken) {
+ // Handle cancellation
+ config.cancelToken.promise.then(function onCanceled(cancel) {
+ if (!request) {
+ return;
+ }
+
+ request.abort();
+ reject(cancel);
+ // Clean up request
+ request = null;
+ });
+ }
+
+ if (requestData === undefined) {
+ requestData = null;
+ }
+
+ // Send the request
+ request.send(requestData);
+ });
+ };
+
+
+ /***/
+ }),
+ /* 9 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var createError = __webpack_require__(10);
+
+ /**
+ * Resolve or reject a Promise based on response status.
+ *
+ * @param {Function} resolve A function that resolves the promise.
+ * @param {Function} reject A function that rejects the promise.
+ * @param {object} response The response.
+ */
+ module.exports = function settle(resolve, reject, response) {
+ var validateStatus = response.config.validateStatus;
+ // Note: status is not exposed by XDomainRequest
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
+ resolve(response);
+ } else {
+ reject(createError(
+ 'Request failed with status code ' + response.status,
+ response.config,
+ null,
+ response.request,
+ response
+ ));
+ }
+ };
+
+
+ /***/
+ }),
+ /* 10 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var enhanceError = __webpack_require__(11);
+
+ /**
+ * Create an Error with the specified message, config, error code, request and response.
+ *
+ * @param {string} message The error message.
+ * @param {Object} config The config.
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
+ * @param {Object} [request] The request.
+ * @param {Object} [response] The response.
+ * @returns {Error} The created error.
+ */
+ module.exports = function createError(message, config, code, request, response) {
+ var error = new Error(message);
+ return enhanceError(error, config, code, request, response);
+ };
+
+
+ /***/
+ }),
+ /* 11 */
+ /***/
+ (function (module, exports) {
+
+ 'use strict';
+
+ /**
+ * Update an Error with the specified config, error code, and response.
+ *
+ * @param {Error} error The error to update.
+ * @param {Object} config The config.
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
+ * @param {Object} [request] The request.
+ * @param {Object} [response] The response.
+ * @returns {Error} The error.
+ */
+ module.exports = function enhanceError(error, config, code, request, response) {
+ error.config = config;
+ if (code) {
+ error.code = code;
+ }
+ error.request = request;
+ error.response = response;
+ return error;
+ };
+
+
+ /***/
+ }),
+ /* 12 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var utils = __webpack_require__(2);
+
+ function encode(val) {
+ return encodeURIComponent(val).
+ replace(/%40/gi, '@').
+ replace(/%3A/gi, ':').
+ replace(/%24/g, '$').
+ replace(/%2C/gi, ',').
+ replace(/%20/g, '+').
+ replace(/%5B/gi, '[').
+ replace(/%5D/gi, ']');
+ }
+
+ /**
+ * Build a URL by appending params to the end
+ *
+ * @param {string} url The base of the url (e.g., http://www.google.com)
+ * @param {object} [params] The params to be appended
+ * @returns {string} The formatted url
+ */
+ module.exports = function buildURL(url, params, paramsSerializer) {
+ /*eslint no-param-reassign:0*/
+ if (!params) {
+ return url;
+ }
+
+ var serializedParams;
+ if (paramsSerializer) {
+ serializedParams = paramsSerializer(params);
+ } else if (utils.isURLSearchParams(params)) {
+ serializedParams = params.toString();
+ } else {
+ var parts = [];
+
+ utils.forEach(params, function serialize(val, key) {
+ if (val === null || typeof val === 'undefined') {
+ return;
+ }
+
+ if (utils.isArray(val)) {
+ key = key + '[]';
+ } else {
+ val = [val];
+ }
+
+ utils.forEach(val, function parseValue(v) {
+ if (utils.isDate(v)) {
+ v = v.toISOString();
+ } else if (utils.isObject(v)) {
+ v = JSON.stringify(v);
+ }
+ parts.push(encode(key) + '=' + encode(v));
+ });
+ });
+
+ serializedParams = parts.join('&');
+ }
+
+ if (serializedParams) {
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
+ }
+
+ return url;
+ };
+
+
+ /***/
+ }),
+ /* 13 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var utils = __webpack_require__(2);
+
+ // Headers whose duplicates are ignored by node
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
+ var ignoreDuplicateOf = [
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
+ 'referer', 'retry-after', 'user-agent'
+ ];
+
+ /**
+ * Parse headers into an object
+ *
+ * ```
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
+ * Content-Type: application/json
+ * Connection: keep-alive
+ * Transfer-Encoding: chunked
+ * ```
+ *
+ * @param {String} headers Headers needing to be parsed
+ * @returns {Object} Headers parsed into an object
+ */
+ module.exports = function parseHeaders(headers) {
+ var parsed = {};
+ var key;
+ var val;
+ var i;
+
+ if (!headers) {
+ return parsed;
+ }
+
+ utils.forEach(headers.split('\n'), function parser(line) {
+ i = line.indexOf(':');
+ key = utils.trim(line.substr(0, i)).toLowerCase();
+ val = utils.trim(line.substr(i + 1));
+
+ if (key) {
+ if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
+ return;
+ }
+ if (key === 'set-cookie') {
+ parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
+ } else {
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
+ }
+ }
+ });
+
+ return parsed;
+ };
+
+
+ /***/
+ }),
+ /* 14 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var utils = __webpack_require__(2);
+
+ module.exports = (
+ utils.isStandardBrowserEnv() ?
+
+ // Standard browser envs have full support of the APIs needed to test
+ // whether the request URL is of the same origin as current location.
+ (function standardBrowserEnv() {
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
+ var urlParsingNode = document.createElement('a');
+ var originURL;
+
+ /**
+ * Parse a URL to discover it's components
+ *
+ * @param {String} url The URL to be parsed
+ * @returns {Object}
+ */
+ function resolveURL(url) {
+ var href = url;
+
+ if (msie) {
+ // IE needs attribute set twice to normalize properties
+ urlParsingNode.setAttribute('href', href);
+ href = urlParsingNode.href;
+ }
+
+ urlParsingNode.setAttribute('href', href);
+
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
+ return {
+ href: urlParsingNode.href,
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
+ host: urlParsingNode.host,
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
+ hostname: urlParsingNode.hostname,
+ port: urlParsingNode.port,
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
+ urlParsingNode.pathname : '/' + urlParsingNode.pathname
+ };
+ }
+
+ originURL = resolveURL(window.location.href);
+
+ /**
+ * Determine if a URL shares the same origin as the current location
+ *
+ * @param {String} requestURL The URL to test
+ * @returns {boolean} True if URL shares the same origin, otherwise false
+ */
+ return function isURLSameOrigin(requestURL) {
+ var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
+ return (parsed.protocol === originURL.protocol &&
+ parsed.host === originURL.host);
+ };
+ })() :
+
+ // Non standard browser envs (web workers, react-native) lack needed support.
+ (function nonStandardBrowserEnv() {
+ return function isURLSameOrigin() {
+ return true;
+ };
+ })()
+ );
+
+
+ /***/
+ }),
+ /* 15 */
+ /***/
+ (function (module, exports) {
+
+ 'use strict';
+
+ // btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
+
+ var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
+
+ function E() {
+ this.message = 'String contains an invalid character';
+ }
+ E.prototype = new Error;
+ E.prototype.code = 5;
+ E.prototype.name = 'InvalidCharacterError';
+
+ function btoa(input) {
+ var str = String(input);
+ var output = '';
+ for (
+ // initialize result and counter
+ var block, charCode, idx = 0, map = chars;
+ // if the next str index does not exist:
+ // change the mapping table to "="
+ // check if d has no fractional digits
+ str.charAt(idx | 0) || (map = '=', idx % 1);
+ // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
+ output += map.charAt(63 & block >> 8 - idx % 1 * 8)
+ ) {
+ charCode = str.charCodeAt(idx += 3 / 4);
+ if (charCode > 0xFF) {
+ throw new E();
+ }
+ block = block << 8 | charCode;
+ }
+ return output;
+ }
+
+ module.exports = btoa;
+
+
+ /***/
+ }),
+ /* 16 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var utils = __webpack_require__(2);
+
+ module.exports = (
+ utils.isStandardBrowserEnv() ?
+
+ // Standard browser envs support document.cookie
+ (function standardBrowserEnv() {
+ return {
+ write: function write(name, value, expires, path, domain, secure) {
+ var cookie = [];
+ cookie.push(name + '=' + encodeURIComponent(value));
+
+ if (utils.isNumber(expires)) {
+ cookie.push('expires=' + new Date(expires).toGMTString());
+ }
+
+ if (utils.isString(path)) {
+ cookie.push('path=' + path);
+ }
+
+ if (utils.isString(domain)) {
+ cookie.push('domain=' + domain);
+ }
+
+ if (secure === true) {
+ cookie.push('secure');
+ }
+
+ document.cookie = cookie.join('; ');
+ },
+
+ read: function read(name) {
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
+ return (match ? decodeURIComponent(match[3]) : null);
+ },
+
+ remove: function remove(name) {
+ this.write(name, '', Date.now() - 86400000);
+ }
+ };
+ })() :
+
+ // Non standard browser env (web workers, react-native) lack needed support.
+ (function nonStandardBrowserEnv() {
+ return {
+ write: function write() {},
+ read: function read() {
+ return null;
+ },
+ remove: function remove() {}
+ };
+ })()
+ );
+
+
+ /***/
+ }),
+ /* 17 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var utils = __webpack_require__(2);
+
+ function InterceptorManager() {
+ this.handlers = [];
+ }
+
+ /**
+ * Add a new interceptor to the stack
+ *
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
+ *
+ * @return {Number} An ID used to remove interceptor later
+ */
+ InterceptorManager.prototype.use = function use(fulfilled, rejected) {
+ this.handlers.push({
+ fulfilled: fulfilled,
+ rejected: rejected
+ });
+ return this.handlers.length - 1;
+ };
+
+ /**
+ * Remove an interceptor from the stack
+ *
+ * @param {Number} id The ID that was returned by `use`
+ */
+ InterceptorManager.prototype.eject = function eject(id) {
+ if (this.handlers[id]) {
+ this.handlers[id] = null;
+ }
+ };
+
+ /**
+ * Iterate over all the registered interceptors
+ *
+ * This method is particularly useful for skipping over any
+ * interceptors that may have become `null` calling `eject`.
+ *
+ * @param {Function} fn The function to call for each interceptor
+ */
+ InterceptorManager.prototype.forEach = function forEach(fn) {
+ utils.forEach(this.handlers, function forEachHandler(h) {
+ if (h !== null) {
+ fn(h);
+ }
+ });
+ };
+
+ module.exports = InterceptorManager;
+
+
+ /***/
+ }),
+ /* 18 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var utils = __webpack_require__(2);
+ var transformData = __webpack_require__(19);
+ var isCancel = __webpack_require__(20);
+ var defaults = __webpack_require__(6);
+ var isAbsoluteURL = __webpack_require__(21);
+ var combineURLs = __webpack_require__(22);
+
+ /**
+ * Throws a `Cancel` if cancellation has been requested.
+ */
+ function throwIfCancellationRequested(config) {
+ if (config.cancelToken) {
+ config.cancelToken.throwIfRequested();
+ }
+ }
+
+ /**
+ * Dispatch a request to the server using the configured adapter.
+ *
+ * @param {object} config The config that is to be used for the request
+ * @returns {Promise} The Promise to be fulfilled
+ */
+ module.exports = function dispatchRequest(config) {
+ throwIfCancellationRequested(config);
+
+ // Support baseURL config
+ if (config.baseURL && !isAbsoluteURL(config.url)) {
+ config.url = combineURLs(config.baseURL, config.url);
+ }
+
+ // Ensure headers exist
+ config.headers = config.headers || {};
+
+ // Transform request data
+ config.data = transformData(
+ config.data,
+ config.headers,
+ config.transformRequest
+ );
+
+ // Flatten headers
+ config.headers = utils.merge(
+ config.headers.common || {},
+ config.headers[config.method] || {},
+ config.headers || {}
+ );
+
+ utils.forEach(
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
+ function cleanHeaderConfig(method) {
+ delete config.headers[method];
+ }
+ );
+
+ var adapter = config.adapter || defaults.adapter;
+
+ return adapter(config).then(function onAdapterResolution(response) {
+ throwIfCancellationRequested(config);
+
+ // Transform response data
+ response.data = transformData(
+ response.data,
+ response.headers,
+ config.transformResponse
+ );
+
+ return response;
+ }, function onAdapterRejection(reason) {
+ if (!isCancel(reason)) {
+ throwIfCancellationRequested(config);
+
+ // Transform response data
+ if (reason && reason.response) {
+ reason.response.data = transformData(
+ reason.response.data,
+ reason.response.headers,
+ config.transformResponse
+ );
+ }
+ }
+
+ return Promise.reject(reason);
+ });
+ };
+
+
+ /***/
+ }),
+ /* 19 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var utils = __webpack_require__(2);
+
+ /**
+ * Transform the data for a request or a response
+ *
+ * @param {Object|String} data The data to be transformed
+ * @param {Array} headers The headers for the request or response
+ * @param {Array|Function} fns A single function or Array of functions
+ * @returns {*} The resulting transformed data
+ */
+ module.exports = function transformData(data, headers, fns) {
+ /*eslint no-param-reassign:0*/
+ utils.forEach(fns, function transform(fn) {
+ data = fn(data, headers);
+ });
+
+ return data;
+ };
+
+
+ /***/
+ }),
+ /* 20 */
+ /***/
+ (function (module, exports) {
+
+ 'use strict';
+
+ module.exports = function isCancel(value) {
+ return !!(value && value.__CANCEL__);
+ };
+
+
+ /***/
+ }),
+ /* 21 */
+ /***/
+ (function (module, exports) {
+
+ 'use strict';
+
+ /**
+ * Determines whether the specified URL is absolute
+ *
+ * @param {string} url The URL to test
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
+ */
+ module.exports = function isAbsoluteURL(url) {
+ // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL).
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
+ // by any combination of letters, digits, plus, period, or hyphen.
+ return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
+ };
+
+
+ /***/
+ }),
+ /* 22 */
+ /***/
+ (function (module, exports) {
+
+ 'use strict';
+
+ /**
+ * Creates a new URL by combining the specified URLs
+ *
+ * @param {string} baseURL The base URL
+ * @param {string} relativeURL The relative URL
+ * @returns {string} The combined URL
+ */
+ module.exports = function combineURLs(baseURL, relativeURL) {
+ return relativeURL ?
+ baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') :
+ baseURL;
+ };
+
+
+ /***/
+ }),
+ /* 23 */
+ /***/
+ (function (module, exports) {
+
+ 'use strict';
+
+ /**
+ * A `Cancel` is an object that is thrown when an operation is canceled.
+ *
+ * @class
+ * @param {string=} message The message.
+ */
+ function Cancel(message) {
+ this.message = message;
+ }
+
+ Cancel.prototype.toString = function toString() {
+ return 'Cancel' + (this.message ? ': ' + this.message : '');
+ };
+
+ Cancel.prototype.__CANCEL__ = true;
+
+ module.exports = Cancel;
+
+
+ /***/
+ }),
+ /* 24 */
+ /***/
+ (function (module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var Cancel = __webpack_require__(23);
+
+ /**
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
+ *
+ * @class
+ * @param {Function} executor The executor function.
+ */
+ function CancelToken(executor) {
+ if (typeof executor !== 'function') {
+ throw new TypeError('executor must be a function.');
+ }
+
+ var resolvePromise;
+ this.promise = new Promise(function promiseExecutor(resolve) {
+ resolvePromise = resolve;
+ });
+
+ var token = this;
+ executor(function cancel(message) {
+ if (token.reason) {
+ // Cancellation has already been requested
+ return;
+ }
+
+ token.reason = new Cancel(message);
+ resolvePromise(token.reason);
+ });
+ }
+
+ /**
+ * Throws a `Cancel` if cancellation has been requested.
+ */
+ CancelToken.prototype.throwIfRequested = function throwIfRequested() {
+ if (this.reason) {
+ throw this.reason;
+ }
+ };
+
+ /**
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
+ * cancels the `CancelToken`.
+ */
+ CancelToken.source = function source() {
+ var cancel;
+ var token = new CancelToken(function executor(c) {
+ cancel = c;
+ });
+ return {
+ token: token,
+ cancel: cancel
+ };
+ };
+
+ module.exports = CancelToken;
+
+
+ /***/
+ }),
+ /* 25 */
+ /***/
+ (function (module, exports) {
+
+ 'use strict';
+
+ /**
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
+ *
+ * Common use case would be to use `Function.prototype.apply`.
+ *
+ * ```js
+ * function f(x, y, z) {}
+ * var args = [1, 2, 3];
+ * f.apply(null, args);
+ * ```
+ *
+ * With `spread` this example can be re-written.
+ *
+ * ```js
+ * spread(function(x, y, z) {})([1, 2, 3]);
+ * ```
+ *
+ * @param {Function} callback
+ * @returns {Function}
+ */
+ module.exports = function spread(callback) {
+ return function wrap(arr) {
+ return callback.apply(null, arr);
+ };
+ };
+
+
+ /***/
+ })
+ /******/
+ ])
+});;
//# sourceMappingURL=axios.map
\ No newline at end of file
diff --git a/express-server/public/javascripts/firebase-app.js b/express-server/public/javascripts/firebase-app.js
index cc0cd4f2..9fae932b 100644
--- a/express-server/public/javascripts/firebase-app.js
+++ b/express-server/public/javascripts/firebase-app.js
@@ -1,50 +1,47 @@
-
-
-// var admin = require("firebase-admin");
-
-// var serviceAccount = require("firebaseAdminKey.json");
-
-// admin.initializeApp({
-// credential: admin.credential.cert(serviceAccount),
-// databaseURL: "https://test-667ca.firebaseio.com"
-// });
-
var msg = firebase.messaging();
msg.requestPermission()
-.then(function(){
-
- return msg.getToken();
-})
-.then(token => {
- console.log("Zugriff auf msg", token);
- updateUser(token);
-
-})
-.catch(err => {
- console.error("Msg Error: ", err);
-})
+ .then(function () {
+
+ return msg.getToken();
+ })
+ .then(token => {
+ console.log("Zugriff auf msg", token);
+ updateUser(token);
+
+ })
+ .catch(err => {
+ console.error("Msg Error: ", err);
+ })
function updateUser(token) {
- firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- $.ajax({
- type: "POST",
- url: "/user",
- data:{
- idtoken: idtoken,
- message_id: token
- },
- success(){
- console.log("User updated");
- },
- error(err){
- console.error("Error: " + err);
- }
- });
- }).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
+ firebase.auth().onAuthStateChanged(function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
+ $.ajax({
+ type: "POST",
+ url: "/user",
+ data: {
+ idtoken: idtoken,
+ message_id: token
+ },
+ success() {
+ console.log("User updated");
+ },
+ error(err) {
+ console.error("Error: " + err);
+ }
+ });
+ }).catch((error) => console.error("Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
+ }
+ });
}
msg.onMessage(payload => {
const title = payload.data.title
- new Notification(title, { body: payload.data.body});
- })
\ No newline at end of file
+ new Notification(title, {
+ body: payload.data.body
+ });
+})
\ No newline at end of file
diff --git a/express-server/public/javascripts/login.js b/express-server/public/javascripts/login.js
index 7c4e8555..0dd949a1 100644
--- a/express-server/public/javascripts/login.js
+++ b/express-server/public/javascripts/login.js
@@ -1,101 +1,110 @@
-
-
// Initialize Firebase
var config = {
- apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
- authDomain: "test-667ca.firebaseapp.com",
- databaseURL: "https://test-667ca.firebaseio.com",
- projectId: "test-667ca",
- storageBucket: "test-667ca.appspot.com",
- messagingSenderId: "221332577314"
+ apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
+ authDomain: "test-667ca.firebaseapp.com",
+ databaseURL: "https://test-667ca.firebaseio.com",
+ projectId: "test-667ca",
+ storageBucket: "test-667ca.appspot.com",
+ messagingSenderId: "221332577314"
};
firebase.initializeApp(config);
-function checkAuth(){
- firebase.auth().onAuthStateChanged(async function(user){
- if(user){
- try{
- firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idToken) {
- console.log("Vor Replace");
+function checkAuth() {
+ firebase.auth().onAuthStateChanged(async function (user) {
+ if (user) {
+ try {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idToken) {
+ console.log("Vor Replace");
- window.location.replace("/dash/" + idToken);
- }).catch(function(error) {
- console.error("Get id token client error: ", error)
- });
- }catch{
- console.error("checkAuth error: ")
- }
-
- // document.getElementById("loginbutton").style.display = "none";
- //
- }else{
- // document.getElementById("loginbutton").style.display = "block";
- console.log("Check Auth error", user)
- }
- })
- var user = firebase.auth().currentUser;
+ window.location.replace("/dash/" + idToken);
+ }).catch(function (error) {
+ console.error("Get id token client error: ", error)
+ });
+ } catch {
+ console.error("checkAuth error: ")
+ }
+
+ // document.getElementById("loginbutton").style.display = "none";
+ //
+ } else {
+ // document.getElementById("loginbutton").style.display = "block";
+ console.log("Check Auth error", user)
+ }
+ })
+ var user = firebase.auth().currentUser;
}
-window.onload = function(){
- checkAuth();
+window.onload = function () {
+ checkAuth();
}
var vue = new Vue({
- el: '#vue-app',
- data:{
+ el: '#vue-app',
+ data: {
+ email: "",
+ password: ""
+ },
+ methods: {
+ login() {
+ var provider = new firebase.auth.GoogleAuthProvider();
+ provider.addScope('profile');
+ provider.addScope('email');
+ firebase.auth().signInWithPopup(provider).then(function (result) {
+ // This gives you a Google Access Token. You can use it to access the Google API.
+ var token = result.credential.accessToken;
+ var idToken = result.credential.idToken;
+ // The signed-in user info.
+ var user = result.user;
+ console.log("Eingelogt");
+ checkAuth();
+ }).catch(function (error) {
+ // Handle Errors here.
+ var errorCode = error.code;
+ var errorMessage = error.message;
+ // The email of the user's account used.
+ var email = error.email;
+ // The firebase.auth.AuthCredential type that was used.
+ var credential = error.credential;
+ });
},
- methods: {
- login(){
- var provider = new firebase.auth.GoogleAuthProvider();
- provider.addScope('profile');
- provider.addScope('email');
- firebase.auth().signInWithPopup(provider).then(function(result) {
- // This gives you a Google Access Token. You can use it to access the Google API.
- var token = result.credential.accessToken;
- var idToken = result.credential.idToken;
- // The signed-in user info.
- var user = result.user;
- console.log("Eingelogt");
- checkAuth();
- }).catch(function(error) {
- // Handle Errors here.
- var errorCode = error.code;
- var errorMessage = error.message;
- // The email of the user's account used.
- var email = error.email;
- // The firebase.auth.AuthCredential type that was used.
- var credential = error.credential;
-
- });
- }
-
- },
-
- mounted() {
- /*axios.post('/user', {
- message_id: 'test',
- })
- .then(function (response) {
- console.log(response);
- })
- .catch(function (error) {
- console.log(error);
- });*/
+ loginemail(){
+ firebase.auth().signInWithEmailAndPassword(this.email, this.password).then(result =>{
+ checkAuth();
+ }).catch(function(error) {
+ // Handle Errors here.
+ var errorCode = error.code;
+ var errorMessage = error.message;
+ // ...
+ });
}
- // mounted() {
- // axios.post('/user', {
- // message_id: 'test',
- // })
- // .then(function (response) {
- // console.log(response);
- // })
- // .catch(function (error) {
- // console.log(error);
- // });
- // }
+ },
+
+ mounted() {
+ /*axios.post('/user', {
+ message_id: 'test',
+ })
+ .then(function (response) {
+ console.log(response);
+ })
+ .catch(function (error) {
+ console.log(error);
+ });*/
+ }
+
+ // mounted() {
+ // axios.post('/user', {
+ // message_id: 'test',
+ // })
+ // .then(function (response) {
+ // console.log(response);
+ // })
+ // .catch(function (error) {
+ // console.log(error);
+ // });
+ // }
});
\ No newline at end of file
diff --git a/express-server/public/javascripts/test.js b/express-server/public/javascripts/test.js
index 9318aef2..a37da646 100644
--- a/express-server/public/javascripts/test.js
+++ b/express-server/public/javascripts/test.js
@@ -1,4 +1,4 @@
-$(document).ready(function() {
+$(document).ready(function () {
refresh();
userinfo();
@@ -13,8 +13,8 @@ $(document).ready(function() {
hidden: false
}
});
-
- $(".btn_invite").click(function() {
+
+ $(".btn_invite").click(function () {
$.ajax({
type: "POST",
url: "/invite",
@@ -25,11 +25,11 @@ $(document).ready(function() {
});
- $(document).on("click", ".btn_detail", function() {
+ $(document).on("click", ".btn_detail", function () {
window.location.replace("/shoppinglist_json/" + $(this).closest("tr").attr("id"));
});
- $(".btn_add").click(function() {
+ $(".btn_add").click(function () {
$.ajax({
type: "POST",
url: "/shoppinglist",
@@ -37,19 +37,21 @@ $(document).ready(function() {
name: $(".name").val(),
description: $(".description").val(),
color: "red"
- }, success(result) {
+ },
+ success(result) {
refresh();
}
});
});
- $(document).on("click", ".btn_delete", function() {
+ $(document).on("click", ".btn_delete", function () {
$.ajax({
type: "DELETE",
url: "/shoppinglist",
data: {
sl_id: $(this).closest("tr").attr("id")
- }, success(result) {
+ },
+ success(result) {
refresh();
}
});
@@ -64,10 +66,10 @@ function refresh() {
type: "GET",
url: "/myshoppinglists",
success(data) {
- for(let item of data) {
- $(".tb_myshoppinglists").append("" + item.name + " | " + item.description +
- " | forward | "
- + "clear |
");
+ for (let item of data) {
+ $(".tb_myshoppinglists").append("" + item.name + " | " + item.description +
+ " | forward | " +
+ "clear |
");
}
}
});
@@ -76,9 +78,9 @@ function refresh() {
type: "GET",
url: "/sharedshoppinglists",
success(data) {
- for(let item of data) {
- $(".tb_sharedshoppinglists").append("" + item.name + " | " + item.description +
- " | forward |
");
+ for (let item of data) {
+ $(".tb_sharedshoppinglists").append("" + item.name + " | " + item.description +
+ " | forward |
");
}
}
});
diff --git a/express-server/public/ocrscan/cam.js b/express-server/public/ocrscan/cam.js
index 04a9c41e..408e4e70 100644
--- a/express-server/public/ocrscan/cam.js
+++ b/express-server/public/ocrscan/cam.js
@@ -7,16 +7,18 @@ $(document).ready(function () {
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
- navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.oGetUserMedia || navigator.msGetUserMedia;
+ navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.oGetUserMedia || navigator.msGetUserMedia;
if (navigator.getUserMedia) {
- navigator.getUserMedia({ video: true }, streamWebcam, throwError);
+ navigator.getUserMedia({
+ video: true
+ }, streamWebcam, throwError);
}
- $(".btnsnap").click(function() {
+ $(".btnsnap").click(function () {
snap();
});
-
+
});
function streamWebcam(stream) {
diff --git a/express-server/public/ocrscan/dropzone.js b/express-server/public/ocrscan/dropzone.js
index 0abe7a73..41dae085 100644
--- a/express-server/public/ocrscan/dropzone.js
+++ b/express-server/public/ocrscan/dropzone.js
@@ -1,12 +1,49 @@
"use strict";
-var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+var _createClass = function () {
+ function defineProperties(target, props) {
+ for (var i = 0; i < props.length; i++) {
+ var descriptor = props[i];
+ descriptor.enumerable = descriptor.enumerable || false;
+ descriptor.configurable = true;
+ if ("value" in descriptor) descriptor.writable = true;
+ Object.defineProperty(target, descriptor.key, descriptor);
+ }
+ }
+ return function (Constructor, protoProps, staticProps) {
+ if (protoProps) defineProperties(Constructor.prototype, protoProps);
+ if (staticProps) defineProperties(Constructor, staticProps);
+ return Constructor;
+ };
+}();
-function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+function _possibleConstructorReturn(self, call) {
+ if (!self) {
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
+ }
+ return call && (typeof call === "object" || typeof call === "function") ? call : self;
+}
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+function _inherits(subClass, superClass) {
+ if (typeof superClass !== "function" && superClass !== null) {
+ throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
+ }
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
+ constructor: {
+ value: subClass,
+ enumerable: false,
+ writable: true,
+ configurable: true
+ }
+ });
+ if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
+}
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+function _classCallCheck(instance, Constructor) {
+ if (!(instance instanceof Constructor)) {
+ throw new TypeError("Cannot call a class as a function");
+ }
+}
/*
*
@@ -487,7 +524,13 @@ var Dropzone = function (_Emitter) {
* Allows you to translate the different units. Starting with `tb` for terabytes and going down to
* `b` for bytes.
*/
- dictFileSizeUnits: { tb: "TB", gb: "GB", mb: "MB", kb: "KB", b: "b" },
+ dictFileSizeUnits: {
+ tb: "TB",
+ gb: "GB",
+ mb: "MB",
+ kb: "KB",
+ b: "b"
+ },
/**
* Called when dropzone initialized
* You can add event listeners here
@@ -1016,7 +1059,7 @@ var Dropzone = function (_Emitter) {
var _this = _possibleConstructorReturn(this, (Dropzone.__proto__ || Object.getPrototypeOf(Dropzone)).call(this));
var fallback = void 0,
- left = void 0;
+ left = void 0;
_this.element = el;
// For backwards compatibility since the version was in the prototype previously
_this.version = Dropzone.version;
@@ -1345,7 +1388,8 @@ var Dropzone = function (_Emitter) {
// "paste": (e) =>
// noPropagation e
// @paste e
- } }];
+ }
+ }];
this.clickableElements.forEach(function (clickableElement) {
return _this3.listeners.push({
@@ -1450,7 +1494,7 @@ var Dropzone = function (_Emitter) {
key: "getFallbackForm",
value: function getFallbackForm() {
var existingFallback = void 0,
- form = void 0;
+ form = void 0;
if (existingFallback = this.getExistingFallback()) {
return existingFallback;
}
@@ -1647,8 +1691,8 @@ var Dropzone = function (_Emitter) {
key: "paste",
value: function paste(e) {
if (__guard__(e != null ? e.clipboardData : undefined, function (x) {
- return x.items;
- }) == null) {
+ return x.items;
+ }) == null) {
return;
}
@@ -2603,8 +2647,8 @@ var Dropzone = function (_Emitter) {
chunk.total = e.total;
chunk.bytesSent = e.loaded;
var fileProgress = 0,
- fileTotal = void 0,
- fileBytesSent = void 0;
+ fileTotal = void 0,
+ fileBytesSent = void 0;
file.upload.progress = 0;
file.upload.total = 0;
file.upload.bytesSent = 0;
@@ -2853,7 +2897,7 @@ var Dropzone = function (_Emitter) {
value: function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0,
- v = c === 'x' ? r : r & 0x3 | 0x8;
+ v = c === 'x' ? r : r & 0x3 | 0x8;
return v.toString(16);
});
}
@@ -2986,8 +3030,9 @@ Dropzone.discover = function () {
// incorrectly **
//
Dropzone.blacklistedBrowsers = [
-// The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API.
-/opera.*(Macintosh|Windows Phone).*version\/12/i];
+ // The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API.
+ /opera.*(Macintosh|Windows Phone).*version\/12/i
+];
// Checks if the browser is supported
Dropzone.isBrowserSupported = function () {
@@ -3041,7 +3086,9 @@ Dropzone.dataURItoBlob = function (dataURI) {
}
// write the ArrayBuffer to a blob
- return new Blob([ab], { type: mimeString });
+ return new Blob([ab], {
+ type: mimeString
+ });
};
// Returns an array without the rejected item
@@ -3095,7 +3142,7 @@ Dropzone.getElement = function (el, name) {
Dropzone.getElements = function (els, name) {
var el = void 0,
- elements = void 0;
+ elements = void 0;
if (els instanceof Array) {
elements = [];
try {
@@ -3248,7 +3295,7 @@ var detectVerticalSquash = function detectVerticalSquash(img) {
ctx.drawImage(img, 0, 0);
var _ctx$getImageData = ctx.getImageData(1, 0, 1, ih),
- data = _ctx$getImageData.data;
+ data = _ctx$getImageData.data;
// search image edge pixel position in case it is squashed vertically.
@@ -3521,10 +3568,11 @@ contentLoaded(window, Dropzone._autoDiscoverFunction);
function __guard__(value, transform) {
return typeof value !== 'undefined' && value !== null ? transform(value) : undefined;
}
+
function __guardMethod__(obj, methodName, transform) {
if (typeof obj !== 'undefined' && obj !== null && typeof obj[methodName] === 'function') {
return transform(obj, methodName);
} else {
return undefined;
}
-}
+}
\ No newline at end of file
diff --git a/express-server/public/ocrscan/ocrscan.js b/express-server/public/ocrscan/ocrscan.js
index 29247d63..88344792 100644
--- a/express-server/public/ocrscan/ocrscan.js
+++ b/express-server/public/ocrscan/ocrscan.js
@@ -1,212 +1,247 @@
var id;
-$(document).ready(function() {
+$(document).ready(function () {
M.AutoInit();
- //initialize all modals
- $('.modal').modal({
- dismissible: false
- });
-
-
- $('.materialboxed').materialbox();
- $('.fixed-action-btn').floatingActionButton();
+ //initialize all modals
+ $('.modal').modal({
+ dismissible: false
+ });
- if ($(window).width() > 600) {
- //large
- $(".col").css("height", "100%");
- }
- else {
- //small
- $(".col").css("height", "50%");
- }
-
- $("#modal1").modal("open");
+ $('.materialboxed').materialbox();
+ $('.fixed-action-btn').floatingActionButton();
- $(".btn-analyze").click(function() {
+ if ($(window).width() > 600) {
+ //large
+ $(".col").css("height", "100%");
+ } else {
+ //small
+ $(".col").css("height", "50%");
+ }
+
+ $("#modal1").modal("open");
+
+
+ $(".btn-analyze").click(function () {
analyzeUploaded();
});
-
-//AJAX
-// Initialize Firebase
-var config = {
- apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
- authDomain: "test-667ca.firebaseapp.com",
- databaseURL: "https://test-667ca.firebaseio.com",
- projectId: "test-667ca",
- storageBucket: "test-667ca.appspot.com",
- messagingSenderId: "221332577314"
- };
+ //AJAX
- firebase.initializeApp(config);
+ // Initialize Firebase
+ var config = {
+ apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
+ authDomain: "test-667ca.firebaseapp.com",
+ databaseURL: "https://test-667ca.firebaseio.com",
+ projectId: "test-667ca",
+ storageBucket: "test-667ca.appspot.com",
+ messagingSenderId: "221332577314"
+ };
- getAllShoppinglists();
+ firebase.initializeApp(config);
- updateUser();
- testSearch();
-
-
-
-function movePurchases(text) {
- firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- $.ajax({
- type: "POST",
- url: "/dones",
- data:{
- idtoken: idtoken,
- sl_id: id,
- billcontent: text
- },
- success(result){
- console.log(result);
- window.location.href = "/dash/" + idtoken
- },
- error(err){
- console.error("Error: " + err);
- }
- });
- }).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
-}
-
-$(".test").click(function() {
- //movePurchases();
getAllShoppinglists();
-});
-$(document).on("click", ".btndash", function() {
- firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- window.location.href = "/dash/" + idtoken
- }).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
-});
+ updateUser();
+ testSearch();
-function analyzeUploaded() {
- $("#modalEND").modal("open");
- var img = document.getElementById("blah");
-
- Tesseract.recognize(img).progress((progress) => {
-
- if (progress.status == "recognizing text") {
- loading = true;
- }
- }).then((result) => {
- loading = false;
- console.log(result.text);
- movePurchases(result.text);
- $(".determinate").css("width", "0%");
- });
-}
-
-setInterval(updateProgress(), 500);
-
-function updateProgress(percent) {
- if(loading == true) {
- $(".determinate").css("width", progress.progress * 100 + "%");
+ function movePurchases(text) {
+ firebase.auth().onAuthStateChanged(function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
+ $.ajax({
+ type: "POST",
+ url: "/dones",
+ data: {
+ idtoken: idtoken,
+ sl_id: id,
+ billcontent: text
+ },
+ success(result) {
+ console.log(result);
+ window.location.href = "/dash/" + idtoken
+ },
+ error(err) {
+ console.error("Error: " + err);
+ }
+ });
+ }).catch((error) => console.error("Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
+ }
+ });
}
-
-}
-function updateUser() {
- firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- $.ajax({
- type: "POST",
- url: "/user",
- data:{
- idtoken: idtoken,
- message_id: "msgtest"
- },
- success(){
- console.log("USer updated");
- },
- error(err){
- console.error("Error: " + err);
- }
- });
- }).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
-}
-
-function testSearch() {
- console.log("dpne");
- $.ajax({
- type: "DELETE",
- url: "/member",
- data: {
- sl_id: "PDADo1iJ",
- uid: "VZT25Xd3rLXEmGGUcrtocbJ9QBu2"
- },
- success(data) {
- console.log(data);
- },
- error(err) {
- console.error(err);
- }
+ $(".test").click(function () {
+ //movePurchases();
+ getAllShoppinglists();
});
-}
-
-function getAllShoppinglists() {
- firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
- $.ajax({
- type: "GET",
- url: "/myshoppinglists",
- data:{
- idtoken: idtoken,
- },
- success(data){
-
- $(".preloader-wrapper").css("display", "none");
- for(let item of data) {
- $(".output").append("" + item.name + "")
- }
-
- },
- error(err){
- console.error("Error: " + err);
+ $(document).on("click", ".btndash", function () {
+ firebase.auth().onAuthStateChanged(function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
+ window.location.href = "/dash/" + idtoken
+ }).catch((error) => console.error("Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
}
});
- }).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
-}
+ });
-$(document).on("click", ".collection-item", function() {
- id = $(this).closest("a").attr("id");
+ function analyzeUploaded() {
- $(".active").removeClass("active");
+ $("#modalEND").modal("open");
- $(this).addClass("active");
-});
+ var img = document.getElementById("blah");
-$(".btncont").click(function() {
- run([{y:100}, {y:0}], $(".r1"));
-});
+ Tesseract.recognize(img).progress((progress) => {
-function run(v, elem){
- //Reverse the array
- var reversed = JSON.parse(JSON.stringify(v)).reverse();
-
- $(v[0]).animate(v[1], {
- //The speed the element moves - lower is faster
- duration: 500,
- step: function(val) {
- //Adding the transform to your element
- elem.css("transform", `translateY(${val}%)`);
+ if (progress.status == "recognizing text") {
+ loading = true;
+ }
+ }).then((result) => {
+ loading = false;
+ console.log(result.text);
+ movePurchases(result.text);
+ $(".determinate").css("width", "0%");
+ });
+ }
+
+ setInterval(updateProgress(), 500);
+
+ function updateProgress(percent) {
+ if (loading == true) {
+ $(".determinate").css("width", progress.progress * 100 + "%");
}
- })
- };
-$(".opt1").click(function() {
- run([{y:0}, {y:-100}], $(".r1"))
+ }
- run([{y:0}, {y:-100}], $(".r2"));
- //$("#modal2").modal("open");
-});
+ function updateUser() {
+ firebase.auth().onAuthStateChanged(function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
+ $.ajax({
+ type: "POST",
+ url: "/user",
+ data: {
+ idtoken: idtoken,
+ message_id: "msgtest"
+ },
+ success() {
+ console.log("USer updated");
+ },
+ error(err) {
+ console.error("Error: " + err);
+ }
+ });
+ }).catch((error) => console.error("Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
+ }
+ });
+ }
-$(".opt2").click(function() {
- // $('.row').animate({'margin-top': '-100%'}, 1000);
-});
+ function testSearch() {
+ console.log("dpne");
+ $.ajax({
+ type: "DELETE",
+ url: "/member",
+ data: {
+ sl_id: "PDADo1iJ",
+ uid: "VZT25Xd3rLXEmGGUcrtocbJ9QBu2"
+ },
+ success(data) {
+ console.log(data);
+ },
+ error(err) {
+ console.error(err);
+ }
+ });
+ }
+
+
+ function getAllShoppinglists() {
+ firebase.auth().onAuthStateChanged(function (user) {
+ if (user) {
+ firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
+ $.ajax({
+ type: "GET",
+ url: "/myshoppinglists",
+ data: {
+ idtoken: idtoken,
+ },
+ success(data) {
+
+ $(".preloader-wrapper").css("display", "none");
+ for (let item of data) {
+ $(".output").append("" + item.name + "")
+ }
+
+ },
+ error(err) {
+ console.error("Error: " + err);
+ }
+ });
+ }).catch((error) => console.error("Get id token client error: ", error));
+ } else {
+ console.log("Check Auth error", user)
+ }
+ });
+ }
+
+ $(document).on("click", ".collection-item", function () {
+ id = $(this).closest("a").attr("id");
+
+ $(".active").removeClass("active");
+
+ $(this).addClass("active");
+ });
+
+ $(".btncont").click(function () {
+ run([{
+ y: 100
+ }, {
+ y: 0
+ }], $(".r1"));
+ });
+
+ function run(v, elem) {
+ //Reverse the array
+ var reversed = JSON.parse(JSON.stringify(v)).reverse();
+
+ $(v[0]).animate(v[1], {
+ //The speed the element moves - lower is faster
+ duration: 500,
+ step: function (val) {
+ //Adding the transform to your element
+ elem.css("transform", `translateY(${val}%)`);
+ }
+ })
+ };
+
+ $(".opt1").click(function () {
+ run([{
+ y: 0
+ }, {
+ y: -100
+ }], $(".r1"))
+
+ run([{
+ y: 0
+ }, {
+ y: -100
+ }], $(".r2"));
+ //$("#modal2").modal("open");
+ });
+
+ $(".opt2").click(function () {
+ // $('.row').animate({'margin-top': '-100%'}, 1000);
+ });
});
@@ -228,5 +263,4 @@ var loading = false;
$(".determinate").css("width", "0%");
});
}
-*/
-
+*/
\ No newline at end of file
diff --git a/express-server/push/push.js b/express-server/push/push.js
index 59257bbb..7f2d5457 100644
--- a/express-server/push/push.js
+++ b/express-server/push/push.js
@@ -1,9 +1,4 @@
-var admin = require('firebase-admin');
-var serviceAccount = require('../login/firebaseAdminKey.json');
-var firebaseAdmin = admin.initializeApp({
- credential: admin.credential.cert(serviceAccount),
- databaseURL: 'https://test-667ca.firebaseio.com'
- });
+
function sendPush(msgtoken, title, text){
var message = {
diff --git a/express-server/routes/index.js b/express-server/routes/index.js
index 0e3b24a3..5ed4adc3 100644
--- a/express-server/routes/index.js
+++ b/express-server/routes/index.js
@@ -8,58 +8,46 @@ var push = require("./../push/push");
var postgres = require("./../db-connect/db-connect");
-// Initialize Firebase
-// const config = {
-// apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
-// authDomain: "test-667ca.firebaseapp.com",
-// databaseURL: "https://test-667ca.firebaseio.com",
-// projectId: "test-667ca",
-// storageBucket: "test-667ca.appspot.com",
-// messagingSenderId: "221332577314"
-// };
-// firebase.initializeApp(config);
-
-
-
-
-
-
-
-
+var admin = require('firebase-admin');
+var serviceAccount = require('../login/firebaseAdminKey.json');
+var firebaseAdmin = admin.initializeApp({
+ credential: admin.credential.cert(serviceAccount),
+ databaseURL: 'https://test-667ca.firebaseio.com'
+ });
//Push
router.get('/push/:msgtoken/:message/:title', function (req, res, next) {
- push.sendPush(req.params.msgtoken, req.params.title, req.params.message);
- var sender = "Message Token: " + req.params.msgtoken + " Message: " + req.params.message + " Title: " + req.params.title;
- res.status(200).send(sender);
+ push.sendPush(req.params.msgtoken, req.params.title, req.params.message);
+ var sender = "Message Token: " + req.params.msgtoken + " Message: " + req.params.message + " Title: " + req.params.title;
+ res.status(200).send(sender);
});
// Login und Dash
-router.get('/', function(req, res, next) {
+router.get('/', function (req, res, next) {
res.render('index');
});
-router.get('/dash/:idtoken', function(req, res, next) {
+router.get('/dash/:idtoken', function (req, res, next) {
// const msgtoken = req.params.msgtoken;
const token = req.params.idtoken;
var uid;
firebaseAdmin.auth().verifyIdToken(token)
- .then(function(decodedToken) {
+ .then(function (decodedToken) {
uid = decodedToken.uid;
// HIER WEITER MACHEN
// uid ist nur hier drinen verfügbar
- }).catch(function(error) {
+ }).catch(function (error) {
console.log(error)
});
-
- res.render('dash');
+
+ res.render('dash');
});
@@ -67,27 +55,25 @@ router.get('/dash/:idtoken', function(req, res, next) {
//GET Own shoppinglists as JSON
-router.get("/myshoppinglists",async function(req, res, next) {
+router.get("/myshoppinglists", async function (req, res, next) {
var token = req.query.idtoken;
console.log("/myshoppinglists idtoken: ", token)
firebaseAdmin.auth().verifyIdToken(token)
- .then(async function(decodedToken) {
+ .then(async function (decodedToken) {
uid = decodedToken.uid;
console.log("uid", uid)
try {
//Get user id: req.session.passport.user.profile.id
res.status(200).send(await postgres.getShoppinglistsAdmin(uid));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
-
- }).catch(function(error) {
+
+ }).catch(function (error) {
console.log(error)
});
-
-
+
+
});
//Test Funktion für Android, liefert die FirebaseAdmin Skd UID
@@ -108,97 +94,89 @@ router.get("/myshoppinglists",async function(req, res, next) {
//GET Shared shoppinglists as JSON
-router.get("/sharedshoppinglists", async function(req, res, next) {
+router.get("/sharedshoppinglists", async function (req, res, next) {
var token = req.query.idtoken;
firebaseAdmin.auth().verifyIdToken(token)
- .then(async function(decodedToken) {
+ .then(async function (decodedToken) {
uid = decodedToken.uid;
console.log("uid", uid)
try {
//Get user id: req.session.passport.user.profile.id
res.status(200).send(await postgres.getShoppinglistsShared(uid));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
-
- }).catch(function(error) {
+
+ }).catch(function (error) {
console.log(error)
});
-
-
+
+
});
//GET ALL SHOPPINGLISTS
-router.get("/shoppinglistsbylink", async function(req, res, next) {
+router.get("/shoppinglistsbylink", async function (req, res, next) {
var token = req.query.idtoken;
firebaseAdmin.auth().verifyIdToken(token)
- .then(async function(decodedToken) {
+ .then(async function (decodedToken) {
uid = decodedToken.uid;
console.log("uid", uid)
try {
//Get user id: req.session.passport.user.profile.id
res.status(200).send(await postgres.getShoppinglistsByLink(req.query.link));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
-
- }).catch(function(error) {
+
+ }).catch(function (error) {
console.log(error)
});
-
-
+
+
});
//POST new shoppinglist
-router.post("/shoppinglist", async function(req, res, next) {
+router.post("/shoppinglist", async function (req, res, next) {
console.log("/shoppinglist idtoken: ", req.body.idtoken)
var token = req.body.idtoken;
-
+
var uid;
firebaseAdmin.auth().verifyIdToken(token)
- .then(async function(decodedToken) {
+ .then(async function (decodedToken) {
uid = decodedToken.uid;
console.log("UID: ", uid);
console.log("So andere sachen: ", req.body.name, req.body.description);
try {
-
+
res.status(200).send(await postgres.newShoppinglist(req.body.name, req.body.description, uid, req.body.color));
sendPush("enG4tJ6LyyU:APA91bEYjUEs7Sdzvu2ivgfqtpzlg42BZLlujDSRg0WLBvfZ_oD4V7cTx2o6MVr4oAdeHaK0wttPMQ85GMMOkgM7xvbHFcwXUG4MCr8JXX16S-OV2CS4ikQ286DOHPtBotbM7pqFTvIM", "Einkaufsliste " + req.body.name + " wurde erstellt!", req.body.description)
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
- }).catch(function(error) {
+ }).catch(function (error) {
console.log(error)
});
- });
+});
//GET Shoppinglist detail
router.get("/shoppinglist_json/:sl_id", async (req, res) => {
var token = req.query.idtoken;
var uid;
firebaseAdmin.auth().verifyIdToken(token)
- .then(async function(decodedToken) {
+ .then(async function (decodedToken) {
uid = decodedToken.uid;
console.log("UID: ", uid);
try {
res.status(200).send(await postgres.displayShoppinglist(req.params.sl_id));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
- }).catch(function(error) {
+ }).catch(function (error) {
console.log(error)
});
-
+
});
@@ -210,41 +188,34 @@ postgres.displayShoppinglist("4tezJYMK");
router.delete("/shoppinglist", async (req, res) => {
try {
res.status(200).send(await postgres.deleteShoppinglist(req.body.sl_id));
- sendPush("enG4tJ6LyyU:APA91bEYjUEs7Sdzvu2ivgfqtpzlg42BZLlujDSRg0WLBvfZ_oD4V7cTx2o6MVr4oAdeHaK0wttPMQ85GMMOkgM7xvbHFcwXUG4MCr8JXX16S-OV2CS4ikQ286DOHPtBotbM7pqFTvIM", "Die Einkaufsliste " + req.body.sl_id + " wurde gelöscht!", "Einkaufsliste wurde geändert")
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
-});
+});
//Group erstellen
router.post("/group", async (req, res) => {
try {
res.status(200).send(await postgres.addGroup(req.body.sl_id, req.body.name, req.body.color, req.body.hidden));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
-
+
});
//Item erstellen
router.post("/item", async (req, res) => {
try {
- res.status(200).send(await postgres.addItem(req.body.group_id, req.body.sl_id, req.body.name, req.body.count));
- }
-
- catch (err) {
+ res.status(200).send(await postgres.addItem(req.body.group_id, req.body.sl_id, req.body.name, req.body.count));
+ } catch (err) {
res.status(400).send(await err);
}
});
router.get("/test1", (req, res) => {
- res.render("test");
+ res.render("test");
});
router.get("/userinfo_json", (req, res) => {
@@ -252,9 +223,9 @@ router.get("/userinfo_json", (req, res) => {
console.log("/userinfo_json idtoken: ", token)
firebaseAdmin.auth().verifyIdToken(token)
- .then(function(decodedToken) {
+ .then(function (decodedToken) {
res.send(decodedToken);
- }).catch(function(error) {
+ }).catch(function (error) {
console.log(error)
});
});
@@ -263,9 +234,7 @@ router.get("/userinfo_json", (req, res) => {
router.put("/shoppinglist", async (req, res) => {
try {
res.status(200).send(await postgres.editShoppinglist(req.body.sl_id, req.body.name, req.body.description, req.body.color));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
});
@@ -275,9 +244,7 @@ router.put("/shoppinglist", async (req, res) => {
router.put("/group", async (req, res) => {
try {
res.status(200).send(await postgres.editGroup(req.body.sl_id, req.body.group_id, req.body.name, req.body.color, req.body.hidden));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
});
@@ -285,29 +252,23 @@ router.put("/group", async (req, res) => {
router.put("/item", async (req, res) => {
try {
res.status(200).send(await postgres.editItem(req.body.sl_id, req.body.group_id, req.body.item_id, req.body.name, req.body.count));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
});
-router.delete("/group", async(req, res) => {
+router.delete("/group", async (req, res) => {
try {
res.status(200).send(await postgres.deleteGroup(req.body.group_id, req.body.sl_id));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
});
-router.delete("/item", async(req, res) => {
+router.delete("/item", async (req, res) => {
try {
res.status(200).send(await postgres.deleteItem(req.body.item_id, req.body.group.id, req.body.sl_id));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
});
@@ -317,9 +278,7 @@ router.delete("/item", async(req, res) => {
router.post("/invite", async (req, res) => {
try {
res.status(200).send(await postgres.createInvite(req.body.sl_id));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
});
@@ -327,9 +286,7 @@ router.post("/invite", async (req, res) => {
router.post("/maninvite", async (req, res) => {
try {
res.status(200).send(await postgres.manInvite(req.body.sl_id, req.body.uid));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(err);
}
@@ -339,9 +296,7 @@ router.post("/maninvite", async (req, res) => {
router.delete("/member", (req, res) => {
try {
postgres.removeMember(req.body.uid, req.body.sl_id)
- }
-
- catch(err) {
+ } catch (err) {
return err;
}
});
@@ -355,56 +310,50 @@ router.post("/invitemember", (req, res) => {
var token = req.body.idtoken;
var uid;
firebaseAdmin.auth().verifyIdToken(token)
- .then(async function(decodedToken) {
+ .then(async function (decodedToken) {
uid = decodedToken.uid;
try {
- console.log("Route LInk inv", req.body.link);
+ console.log("Route LInk inv", req.body.link);
res.status(200).send(await postgres.verifyInvite(req.body.link, uid));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
- }).catch(function(error) {
+ }).catch(function (error) {
console.log(error)
});
});
//Update User
-router.post("/user", async function(req, res, next) {
+router.post("/user", async function (req, res, next) {
console.log("/shoppinglist idtoken: ", req.body.idtoken)
var token = req.body.idtoken;
-
+
var uid;
firebaseAdmin.auth().verifyIdToken(token)
- .then(async function(decodedToken) {
+ .then(async function (decodedToken) {
uid = decodedToken.uid;
console.log("UID: ", uid);
console.log("So andere sachen: ", req.body.name, req.body.description);
try {
-
+
res.status(200).send(await postgres.updateUser(uid, req.body.message_id, decodedToken.name, decodedToken.picture, decodedToken.email));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
- }).catch(function(error) {
+ }).catch(function (error) {
console.log(error)
});
});
router.get("/users", async (req, res) => {
try {
- res.status(200).send(await postgres.searchUsers(req.query.search));
- }
-
- catch(err) {
+ res.status(200).send(await postgres.searchUsers(req.query.search));
+ } catch (err) {
res.status(400).send(err);
}
-
+
});
@@ -417,19 +366,17 @@ router.post("/donepurchases", (req, res) => {
var token = req.query.idtoken;
var uid;
firebaseAdmin.auth().verifyIdToken(token)
- .then(async function(decodedToken) {
+ .then(async function (decodedToken) {
uid = decodedToken.uid;
try {
console.log("test");
- }
-
- catch(err) {
+ } catch (err) {
console.error(error);
}
- }).catch( async function(error) {
+ }).catch(async function (error) {
console.log(error)
});
-
+
});
@@ -438,53 +385,49 @@ router.get("/donepurchases", (req, res) => {
var token = req.query.idtoken;
var uid;
firebaseAdmin.auth().verifyIdToken(token)
- .then(async function(decodedToken) {
+ .then(async function (decodedToken) {
uid = decodedToken.uid;
try {
res.status(200).send(await postgres.getDonePurchases(uid));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
- }).catch( async function(error) {
+ }).catch(async function (error) {
console.log(error)
});
-
+
});
//OCR Scan
-router.get("/scan/", async (req, res,) => {
+router.get("/scan/", async (req, res, ) => {
res.render("ocrscan");
});
-router.post("/dones", async function(req, res, next) {
+router.post("/dones", async function (req, res, next) {
console.log("/shoppinglist idtoken: ", req.body.idtoken)
var token = req.body.idtoken;
-
+
var uid;
firebaseAdmin.auth().verifyIdToken(token)
- .then(async function(decodedToken) {
+ .then(async function (decodedToken) {
uid = decodedToken.uid;
console.log("UID: ", uid);
console.log("So andere sachen: ", req.body.name, req.body.description);
try {
-
+
res.status(200).send(await postgres.moveDoneItems(uid, req.body.sl_id, req.body.billcontent));
- }
-
- catch(err) {
+ } catch (err) {
res.status(400).send(await err);
}
- }).catch(function(error) {
+ }).catch(function (error) {
console.log(error)
});
- });
-
-
+});
-module.exports = router;
+
+
+module.exports = router;
\ No newline at end of file
diff --git a/express-server/routes/users.js b/express-server/routes/users.js
index 623e4302..90b07a36 100644
--- a/express-server/routes/users.js
+++ b/express-server/routes/users.js
@@ -2,8 +2,8 @@ var express = require('express');
var router = express.Router();
/* GET users listing. */
-router.get('/', function(req, res, next) {
+router.get('/', function (req, res, next) {
res.send('respond with a resource');
});
-module.exports = router;
+module.exports = router;
\ No newline at end of file
diff --git a/express-server/test/greenlock.js b/express-server/test/greenlock.js
index c10e6038..0f16ceb8 100644
--- a/express-server/test/greenlock.js
+++ b/express-server/test/greenlock.js
@@ -1,13 +1,15 @@
#!/usr/bin/env node
+
var Greenlock = require('../');
var greenlock = Greenlock.create({
- version: 'draft-11'
-, server: 'https://acme-staging-v02.api.letsencrypt.org/directory'
-, agreeTos: true
-, approvedDomains: [ 'example.com', 'www.example.com' ]
-, configDir: require('path').join(require('os').tmpdir(), 'acme')
+ version: 'draft-11',
+ server: 'https://acme-staging-v02.api.letsencrypt.org/directory',
+ agreeTos: true,
+ approvedDomains: ['example.com', 'www.example.com'],
+ configDir: require('path').join(require('os').tmpdir(), 'acme')
-, app: require('express')().use('/', function (req, res) {
+ ,
+ app: require('express')().use('/', function (req, res) {
res.setHeader('Content-Type', 'text/html; charset=utf-8');
res.end('Hello, World!\n\n💚 🔒.js');
})
@@ -72,4 +74,4 @@ var server5 = greenlock.listen(10080, 10443, function () {
var server6 = greenlock.listen('[::]:11080', '[::1]:11443');
-var server7 = greenlock.listen('/tmp/gl.plain.sock', '/tmp/gl.sec.sock');
+var server7 = greenlock.listen('/tmp/gl.plain.sock', '/tmp/gl.sec.sock');
\ No newline at end of file
diff --git a/express-server/views/androidlogin.ejs b/express-server/views/androidlogin.ejs
deleted file mode 100644
index 5b97e2cd..00000000
--- a/express-server/views/androidlogin.ejs
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/express-server/views/dash.ejs b/express-server/views/dash.ejs
index 32cc965b..727568fa 100644
--- a/express-server/views/dash.ejs
+++ b/express-server/views/dash.ejs
@@ -1,16 +1,19 @@
-
+
+
-
+
-
-
+
+
+
@@ -50,71 +54,74 @@
-
+
-
+
-
Group hinzufügen
+
+ Group hinzufügen
+
-
-
+
+
-
+
@@ -122,33 +129,36 @@
-
+
-
Item hinzufügen
+
+ Item hinzufügen
+
-
-
+
+
-
+
-
-
+
+
-
+
@@ -158,66 +168,67 @@
-
+
+
@@ -240,5 +251,6 @@
-
+
+
\ No newline at end of file
diff --git a/express-server/views/error.ejs b/express-server/views/error.ejs
index 7cf94edf..74a7b3d7 100644
--- a/express-server/views/error.ejs
+++ b/express-server/views/error.ejs
@@ -1,3 +1,7 @@
-
<%= message %>
-
<%= error.status %>
-
<%= error.stack %>
+
+ <%= message %>
+
+
+ <%= error.status %>
+
+
<%= error.stack %>
\ No newline at end of file
diff --git a/express-server/views/index.ejs b/express-server/views/index.ejs
index 94c62981..f2482fa6 100644
--- a/express-server/views/index.ejs
+++ b/express-server/views/index.ejs
@@ -1,22 +1,31 @@
-
-
-
-
-
+
-
-
+
+
-