From 05db66aad0913644e495bf2635e82470c84a9792 Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Mon, 8 Jul 2019 09:45:48 +0200 Subject: [PATCH 01/14] Add react router. --- web/package.json | 1 + yarn.lock | 105 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 104 insertions(+), 2 deletions(-) diff --git a/web/package.json b/web/package.json index 445ba2b1cdab..ba3e595cc53c 100644 --- a/web/package.json +++ b/web/package.json @@ -8,6 +8,7 @@ "prop-types": "^15.7.2", "react": "^16.8.6", "react-dom": "^16.8.6", + "react-router-dom": "^5.0.1", "react-textarea-autosize": "^7.1.0", "rebass": "^3.1.1", "rebass-extend": "^1.0.1", diff --git a/yarn.lock b/yarn.lock index fe684935dd4f..0562d76e450d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -766,6 +766,13 @@ dependencies: regenerator-runtime "^0.13.2" +"@babel/runtime@^7.4.0": + version "7.5.1" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.5.1.tgz#51b56e216e87103ab3f7d6040b464c538e242888" + integrity sha512-g+hmPKs16iewFSmW57NkH9xpPkuYD1RV3UE2BCkXx9j+nhhRb9hsiSxPmEa67j35IecTQdn4iyMtHMbt5VoREg== + dependencies: + regenerator-runtime "^0.13.2" + "@babel/template@^7.1.0", "@babel/template@^7.4.4": version "7.4.4" resolved "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz#f4b88d1225689a08f5bc3a17483545be9e4ed237" @@ -3319,6 +3326,11 @@ graphql@^14.3.1, graphql@^14.4.2: dependencies: iterall "^1.2.2" +gud@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/gud/-/gud-1.0.0.tgz#a489581b17e6a70beca9abe3ae57de7a499852c0" + integrity sha512-zGEOVKFM5sVPPrYs7J5/hYEw2Pof8KCyOwyhG8sAF26mCAeUFAcYPu1mwB7hhpIP29zOIBaDqwuHdLp0jvZXjw== + handle-thing@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-2.0.0.tgz#0e039695ff50c93fc288557d696f3c1dc6776754" @@ -3398,6 +3410,18 @@ he@1.2.x: resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== +history@^4.9.0: + version "4.9.0" + resolved "https://registry.yarnpkg.com/history/-/history-4.9.0.tgz#84587c2068039ead8af769e9d6a6860a14fa1bca" + integrity sha512-H2DkjCjXf0Op9OAr6nJ56fcRkTSNrUiv41vNJ6IswJjif6wlpZK0BTfFbi7qK9dXLSYZxkq5lBsj3vUjlYBYZA== + dependencies: + "@babel/runtime" "^7.1.2" + loose-envify "^1.2.0" + resolve-pathname "^2.2.0" + tiny-invariant "^1.0.2" + tiny-warning "^1.0.0" + value-equal "^0.4.0" + hmac-drbg@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" @@ -3407,6 +3431,13 @@ hmac-drbg@^1.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" +hoist-non-react-statics@^3.1.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz#b09178f0122184fb95acf525daaecb4d8f45958b" + integrity sha512-0XsbTXxgiaCDYDIWFcwkmerZPSwywfUqYmwT4jzewKTQSWoE6FCMoUVOeBJWK3E/CrWbxRG3m5GzY4lnIwGRBA== + dependencies: + react-is "^16.7.0" + homedir-polyfill@^1.0.1: version "1.0.3" resolved "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8" @@ -3921,6 +3952,11 @@ is-wsl@^1.1.0: resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" integrity sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0= +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8= + isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" @@ -4139,7 +4175,7 @@ long@^4.0.0: resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== -loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0: +loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.2.0, loose-envify@^1.3.1, loose-envify@^1.4.0: version "1.4.0" resolved "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== @@ -4322,6 +4358,15 @@ mimic-fn@^2.0.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== +mini-create-react-context@^0.3.0: + version "0.3.2" + resolved "https://registry.yarnpkg.com/mini-create-react-context/-/mini-create-react-context-0.3.2.tgz#79fc598f283dd623da8e088b05db8cddab250189" + integrity sha512-2v+OeetEyliMt5VHMXsBhABoJ0/M4RCe7fatd/fBy6SMiKazUSEt3gxxypfnk2SHMkdBYvorHRoQxuGoiwbzAw== + dependencies: + "@babel/runtime" "^7.4.0" + gud "^1.0.0" + tiny-warning "^1.0.2" + minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" @@ -4972,6 +5017,13 @@ path-to-regexp@0.1.7: resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w= +path-to-regexp@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d" + integrity sha1-Wf3g9DW62suhA6hOnTvGTpa5k30= + dependencies: + isarray "0.0.1" + pbkdf2@^3.0.3: version "3.0.17" resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.17.tgz#976c206530617b14ebb32114239f7b09336e93a6" @@ -5322,7 +5374,7 @@ react-dom@^16.8.6: prop-types "^15.6.2" scheduler "^0.13.6" -react-is@^16.6.0, react-is@^16.8.1: +react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1: version "16.8.6" resolved "https://registry.npmjs.org/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16" integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA== @@ -5337,6 +5389,35 @@ react-reconciler@^0.20.0: prop-types "^15.6.2" scheduler "^0.13.6" +react-router-dom@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-5.0.1.tgz#ee66f4a5d18b6089c361958e443489d6bab714be" + integrity sha512-zaVHSy7NN0G91/Bz9GD4owex5+eop+KvgbxXsP/O+iW1/Ln+BrJ8QiIR5a6xNPtrdTvLkxqlDClx13QO1uB8CA== + dependencies: + "@babel/runtime" "^7.1.2" + history "^4.9.0" + loose-envify "^1.3.1" + prop-types "^15.6.2" + react-router "5.0.1" + tiny-invariant "^1.0.2" + tiny-warning "^1.0.0" + +react-router@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/react-router/-/react-router-5.0.1.tgz#04ee77df1d1ab6cb8939f9f01ad5702dbadb8b0f" + integrity sha512-EM7suCPNKb1NxcTZ2LEOWFtQBQRQXecLxVpdsP4DW4PbbqYWeRiLyV/Tt1SdCrvT2jcyXAXmVTmzvSzrPR63Bg== + dependencies: + "@babel/runtime" "^7.1.2" + history "^4.9.0" + hoist-non-react-statics "^3.1.0" + loose-envify "^1.3.1" + mini-create-react-context "^0.3.0" + path-to-regexp "^1.7.0" + prop-types "^15.6.2" + react-is "^16.6.0" + tiny-invariant "^1.0.2" + tiny-warning "^1.0.0" + react-textarea-autosize@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/react-textarea-autosize/-/react-textarea-autosize-7.1.0.tgz#3132cb77e65d94417558d37c0bfe415a5afd3445" @@ -5557,6 +5638,11 @@ resolve-from@^3.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748" integrity sha1-six699nWiBvItuZTM17rywoYh0g= +resolve-pathname@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/resolve-pathname/-/resolve-pathname-2.2.0.tgz#7e9ae21ed815fd63ab189adeee64dc831eefa879" + integrity sha512-bAFz9ld18RzJfddgrO2e/0S2O81710++chRMUxHjXOYKF6jTAMrUNZrEZ1PvV0zlhfjidm08iRPdTLPno1FuRg== + resolve-url@^0.2.1: version "0.2.1" resolved "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" @@ -6225,6 +6311,16 @@ timers-browserify@^2.0.4: dependencies: setimmediate "^1.0.4" +tiny-invariant@^1.0.2: + version "1.0.4" + resolved "https://registry.yarnpkg.com/tiny-invariant/-/tiny-invariant-1.0.4.tgz#346b5415fd93cb696b0c4e8a96697ff590f92463" + integrity sha512-lMhRd/djQJ3MoaHEBrw8e2/uM4rs9YMNk0iOr8rHQ0QdbM7D4l0gFl3szKdeixrlyfm9Zqi4dxHCM2qVG8ND5g== + +tiny-warning@^1.0.0, tiny-warning@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/tiny-warning/-/tiny-warning-1.0.2.tgz#1dfae771ee1a04396bdfde27a3adcebc6b648b28" + integrity sha512-rru86D9CpQRLvsFG5XFdy0KdLAvjdQDyZCsRcuu60WtzFylDM3eAWSxEVz5kzL2Gp544XiUvPbVKtOA/txLi9Q== + to-arraybuffer@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" @@ -6544,6 +6640,11 @@ v8flags@^3.1.1: dependencies: homedir-polyfill "^1.0.1" +value-equal@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/value-equal/-/value-equal-0.4.0.tgz#c5bdd2f54ee093c04839d71ce2e4758a6890abc7" + integrity sha512-x+cYdNnaA3CxvMaTX0INdTCN8m8aF2uY9BvEqmxuYp8bL09cs/kWVQPVGcA35fMktdOsP69IgU7wFj/61dJHEw== + vary@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" From 3bb853472b8185eccfc9789d002da5bb656da416 Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Mon, 8 Jul 2019 09:53:54 +0200 Subject: [PATCH 02/14] Rename entry points to index.{html|js|css}. --- web/config/webpack.common.js | 4 ++-- web/src/{global.css => index.css} | 0 web/src/{template.html => index.html} | 0 web/src/index.js | 17 +++++++++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) rename web/src/{global.css => index.css} (100%) rename web/src/{template.html => index.html} (100%) create mode 100644 web/src/index.js diff --git a/web/config/webpack.common.js b/web/config/webpack.common.js index 8c6f80fe6fe0..7df73f66b3ba 100644 --- a/web/config/webpack.common.js +++ b/web/config/webpack.common.js @@ -6,11 +6,11 @@ const DirectoryNamedWebpackPlugin = require("directory-named-webpack-plugin"); module.exports = { entry: { - app: path.resolve(__dirname, "../src/App.js") + app: path.resolve(__dirname, "../src/index.js") }, plugins: [ new HtmlWebpackPlugin({ - template: "./src/template.html" + template: "./src/index.html" }), new webpack.ProvidePlugin({ React: "react", diff --git a/web/src/global.css b/web/src/index.css similarity index 100% rename from web/src/global.css rename to web/src/index.css diff --git a/web/src/template.html b/web/src/index.html similarity index 100% rename from web/src/template.html rename to web/src/index.html diff --git a/web/src/index.js b/web/src/index.js new file mode 100644 index 000000000000..7d1f3b222e49 --- /dev/null +++ b/web/src/index.js @@ -0,0 +1,17 @@ +import ReactDOM from "react-dom"; +import { GraphQLProvider } from "@hammerframework/hammer-web"; +import { ThemeProvider } from "styled-components"; + +import theme from "src/lib/theme"; + +import "./index.css"; +import App from "./App"; + +ReactDOM.render( + + + + + , + document.getElementById("hammer-app") +); From 0255c85c573452c943655c9ad83a000b56591876 Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Mon, 8 Jul 2019 09:59:21 +0200 Subject: [PATCH 03/14] Move InvoicePage. --- web/src/pages/{index.js => InvoicePage/InvoicePage.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename web/src/pages/{index.js => InvoicePage/InvoicePage.js} (100%) diff --git a/web/src/pages/index.js b/web/src/pages/InvoicePage/InvoicePage.js similarity index 100% rename from web/src/pages/index.js rename to web/src/pages/InvoicePage/InvoicePage.js From 2d316495989441e185efe8f97fb19f087bc8aca9 Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Mon, 8 Jul 2019 09:59:43 +0200 Subject: [PATCH 04/14] Use router. --- web/src/App.js | 17 ----------------- web/src/index.js | 4 ++-- web/src/pages/Router.js | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 19 deletions(-) delete mode 100644 web/src/App.js create mode 100644 web/src/pages/Router.js diff --git a/web/src/App.js b/web/src/App.js deleted file mode 100644 index 751ca4d2d769..000000000000 --- a/web/src/App.js +++ /dev/null @@ -1,17 +0,0 @@ -import ReactDOM from "react-dom"; -import { GraphQLProvider } from "@hammerframework/hammer-web"; -import { ThemeProvider } from "styled-components"; - -import "./global.css"; -import theme from "src/lib/theme"; -import InvoicePage from "src/pages"; - -// TODO: Add Router -ReactDOM.render( - - - - - , - document.getElementById("hammer-app") -); diff --git a/web/src/index.js b/web/src/index.js index 7d1f3b222e49..3d29cbb13a90 100644 --- a/web/src/index.js +++ b/web/src/index.js @@ -3,14 +3,14 @@ import { GraphQLProvider } from "@hammerframework/hammer-web"; import { ThemeProvider } from "styled-components"; import theme from "src/lib/theme"; +import Router from "src/pages/Router"; import "./index.css"; -import App from "./App"; ReactDOM.render( - + , document.getElementById("hammer-app") diff --git a/web/src/pages/Router.js b/web/src/pages/Router.js new file mode 100644 index 000000000000..fed2a2ef2dad --- /dev/null +++ b/web/src/pages/Router.js @@ -0,0 +1,15 @@ +import { BrowserRouter, Route, Link } from "react-router-dom"; + +import InvoicePage from "./InvoicePage"; + +const Router = () => { + return ( + + <> + + + + ); +}; + +export default Router; From 44465180572eb87695c84d650d1d9a0eb2d3b590 Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Tue, 9 Jul 2019 10:17:29 +0200 Subject: [PATCH 05/14] Get router working. --- web/.babelrc | 1 + web/package.json | 3 +++ web/src/index.js | 21 +++++++++++++++- web/src/pages/Router.js | 10 +++++--- yarn.lock | 53 +++++++++++++++++++++++++++++++++++++---- 5 files changed, 79 insertions(+), 9 deletions(-) diff --git a/web/.babelrc b/web/.babelrc index 4133323fba06..e13d5285010a 100644 --- a/web/.babelrc +++ b/web/.babelrc @@ -11,6 +11,7 @@ ] ], "plugins": [ + "@babel/plugin-transform-runtime", [ "babel-plugin-module-resolver", { diff --git a/web/package.json b/web/package.json index ba3e595cc53c..c753e2a191c3 100644 --- a/web/package.json +++ b/web/package.json @@ -3,6 +3,8 @@ "version": "0.1.0", "private": true, "dependencies": { + "@auth0/auth0-spa-js": "^1.0.2", + "@babel/runtime": "^7.5.1", "@hammerframework/hammer-web": "0.0.0", "immer": "^3.1.3", "prop-types": "^15.7.2", @@ -16,6 +18,7 @@ "styled-system": "^5.0.12" }, "devDependencies": { + "@babel/plugin-transform-runtime": "^7.5.0", "babel-loader": "^8.0.6", "babel-plugin-module-resolver": "^3.2.0", "babel-plugin-styled-components": "^1.10.6", diff --git a/web/src/index.js b/web/src/index.js index 3d29cbb13a90..bcc056b5bf7e 100644 --- a/web/src/index.js +++ b/web/src/index.js @@ -2,15 +2,34 @@ import ReactDOM from "react-dom"; import { GraphQLProvider } from "@hammerframework/hammer-web"; import { ThemeProvider } from "styled-components"; +import { Auth0Provider } from "src/lib/auth0"; + import theme from "src/lib/theme"; import Router from "src/pages/Router"; import "./index.css"; +const onRedirectCallback = appState => { + window.history.replaceState( + {}, + document.title, + appState && appState.targetUrl + ? appState.targetUrl + : window.location.pathname + ); +}; + ReactDOM.render( - + + + , document.getElementById("hammer-app") diff --git a/web/src/pages/Router.js b/web/src/pages/Router.js index fed2a2ef2dad..7e37128f0623 100644 --- a/web/src/pages/Router.js +++ b/web/src/pages/Router.js @@ -1,13 +1,17 @@ -import { BrowserRouter, Route, Link } from "react-router-dom"; +import { BrowserRouter, Route, Switch } from "react-router-dom"; + +import { SecureRoute } from "src/lib/auth0"; import InvoicePage from "./InvoicePage"; +import Profile from "./Profile"; const Router = () => { return ( - <> + - + + ); }; diff --git a/yarn.lock b/yarn.lock index 0562d76e450d..a33f7f8bc559 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14,6 +14,17 @@ resolved "https://registry.yarnpkg.com/@apollographql/graphql-playground-html/-/graphql-playground-html-1.6.20.tgz#bf9f2acdf319c0959fad8ec1239741dd2ead4e8d" integrity sha512-3LWZa80HcP70Pl+H4KhLDJ7S0px+9/c8GTXdl6SpunRecUaB27g/oOQnAjNHLHdbWuGE0uyqcuGiTfbKB3ilaQ== +"@auth0/auth0-spa-js@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@auth0/auth0-spa-js/-/auth0-spa-js-1.0.2.tgz#6049e5cbc1a26388d4db0ea0323bc5ea7c0fc210" + integrity sha512-r8D48VcjjlmM2VQ4uG5wkiMP4LCg39/I2DGk4R6t0anbQCP/PfF/n/kIQnNWfa6PDSkKxP6UVfthjPU3TKN0Cw== + dependencies: + es-cookie "^1.2.0" + fast-text-encoding "^1.0.0" + qs "^6.5.1" + ts-polyfill "^3.0.1" + unfetch "^4.1.0" + "@babel/cli@^7.5.0": version "7.5.0" resolved "https://registry.npmjs.org/@babel/cli/-/cli-7.5.0.tgz#f403c930692e28ecfa3bf02a9e7562b474f38271" @@ -626,6 +637,16 @@ dependencies: "@babel/helper-plugin-utils" "^7.0.0" +"@babel/plugin-transform-runtime@^7.5.0": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.5.0.tgz#45242c2c9281158c5f06d25beebac63e498a284e" + integrity sha512-LmPIZOAgTLl+86gR9KjLXex6P/lRz1fWEjTz6V6QZMmKie51ja3tvzdwORqhHc4RWR8TcZ5pClpRWs0mlaA2ng== + dependencies: + "@babel/helper-module-imports" "^7.0.0" + "@babel/helper-plugin-utils" "^7.0.0" + resolve "^1.8.1" + semver "^5.5.1" + "@babel/plugin-transform-shorthand-properties@^7.2.0": version "7.2.0" resolved "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.2.0.tgz#6333aee2f8d6ee7e28615457298934a3b46198f0" @@ -766,7 +787,7 @@ dependencies: regenerator-runtime "^0.13.2" -"@babel/runtime@^7.4.0": +"@babel/runtime@^7.4.0", "@babel/runtime@^7.5.1": version "7.5.1" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.5.1.tgz#51b56e216e87103ab3f7d6040b464c538e242888" integrity sha512-g+hmPKs16iewFSmW57NkH9xpPkuYD1RV3UE2BCkXx9j+nhhRb9hsiSxPmEa67j35IecTQdn4iyMtHMbt5VoREg== @@ -2242,7 +2263,7 @@ core-js@^2.6.5: resolved "https://registry.npmjs.org/core-js/-/core-js-2.6.9.tgz#6b4b214620c834152e179323727fc19741b084f2" integrity sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A== -core-js@^3.0.0, core-js@^3.0.1, core-js@^3.1.4: +core-js@^3.0.0, core-js@^3.0.1, core-js@^3.1.3, core-js@^3.1.4: version "3.1.4" resolved "https://registry.npmjs.org/core-js/-/core-js-3.1.4.tgz#3a2837fc48e582e1ae25907afcd6cf03b0cc7a07" integrity sha512-YNZN8lt82XIMLnLirj9MhKDFZHalwzzrL9YLt6eb0T5D0EDl4IQ90IGkua8mHbnxNrkj1d8hbdizMc0Qmg1WnQ== @@ -2725,6 +2746,11 @@ es-abstract@^1.5.1: is-regex "^1.0.4" object-keys "^1.0.12" +es-cookie@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/es-cookie/-/es-cookie-1.2.0.tgz#1f942d37f67ebc27739aa3f35cf9432cf2ee3ae9" + integrity sha512-Rq23x7fV2NRhDbYHA+ebMUHJGyrHWtLd+xFoQ+Tq5kpsAv6FmqpC/SFdDpFJWiwNW7XUhG3GDxVKymDz7KxSRQ== + es-to-primitive@^1.2.0: version "1.2.0" resolved "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz#edf72478033456e8dda8ef09e00ad9650707f377" @@ -2927,6 +2953,11 @@ fast-json-stable-stringify@^2.0.0: resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= +fast-text-encoding@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fast-text-encoding/-/fast-text-encoding-1.0.0.tgz#3e5ce8293409cfaa7177a71b9ca84e1b1e6f25ef" + integrity sha512-R9bHCvweUxxwkDwhjav5vxpFvdPGlVngtqmx4pIZfSUhM/Q4NiIUHB456BAf+Q1Nwu3HEZYONtu+Rya+af4jiQ== + faye-websocket@^0.10.0: version "0.10.0" resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.10.0.tgz#4e492f8d04dfb6f89003507f6edbf2d501e7c6f4" @@ -5299,7 +5330,7 @@ punycode@^2.1.0: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== -qs@6.7.0, qs@^6.7.0: +qs@6.7.0, qs@^6.5.1, qs@^6.7.0: version "6.7.0" resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== @@ -5648,7 +5679,7 @@ resolve-url@^0.2.1: resolved "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= -resolve@^1.3.2, resolve@^1.4.0: +resolve@^1.3.2, resolve@^1.4.0, resolve@^1.8.1: version "1.11.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.11.1.tgz#ea10d8110376982fef578df8fc30b9ac30a07a3e" integrity sha512-vIpgF6wfuJOZI7KKKSP+HmiKggadPQAdsp5HiC1mvqnfp0gF1vdwgBWZIdrVft9pgqoMFQN+R7BSWZiBxx+BBw== @@ -5758,7 +5789,7 @@ semver-diff@^2.0.0: dependencies: semver "^5.0.3" -semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.6.0, semver@^5.7.0: +semver@^5.0.3, semver@^5.1.0, semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0, semver@^5.7.0: version "5.7.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b" integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA== @@ -6390,6 +6421,13 @@ ts-invariant@^0.4.0: dependencies: tslib "^1.9.3" +ts-polyfill@^3.0.1: + version "3.5.1" + resolved "https://registry.yarnpkg.com/ts-polyfill/-/ts-polyfill-3.5.1.tgz#2b550f4e405b78bb36c68415f203e5e11de1d8f1" + integrity sha512-IrwtFfM7ryDo3bM7c23KRXVaTCKy7Lwfl1hXkuorpBnvSffSuoD474qBPX6dggH2/H2C10zaYYmZiMia2oDJUw== + dependencies: + core-js "^3.1.3" + tslib@^1.9.0, tslib@^1.9.3: version "1.10.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" @@ -6428,6 +6466,11 @@ undefsafe@^2.0.2: dependencies: debug "^2.2.0" +unfetch@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.1.0.tgz#6ec2dd0de887e58a4dee83a050ded80ffc4137db" + integrity sha512-crP/n3eAPUJxZXM9T80/yv0YhkTEx2K1D3h7D1AJM6fzsWZrxdyRuLN0JH/dkZh1LNH8LxCnBzoPFCPbb2iGpg== + unicode-canonical-property-names-ecmascript@^1.0.4: version "1.0.4" resolved "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz#2619800c4c825800efdd8343af7dd9933cbe2818" From 59524c9dff9bbeaa12d021a4cf81be9bb7ad2f8f Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Tue, 9 Jul 2019 10:17:50 +0200 Subject: [PATCH 06/14] Add some user tools. --- web/src/components/AppBar.js | 46 +++++++++++------ web/src/lib/auth0/SecureRoute.js | 23 +++++++++ web/src/lib/auth0/auth0.js | 89 ++++++++++++++++++++++++++++++++ web/src/pages/Profile/Profile.js | 23 +++++++++ 4 files changed, 164 insertions(+), 17 deletions(-) create mode 100644 web/src/lib/auth0/SecureRoute.js create mode 100644 web/src/lib/auth0/auth0.js create mode 100644 web/src/pages/Profile/Profile.js diff --git a/web/src/components/AppBar.js b/web/src/components/AppBar.js index 8aff967da274..f416eeadfb25 100644 --- a/web/src/components/AppBar.js +++ b/web/src/components/AppBar.js @@ -1,23 +1,35 @@ -import { Box } from "src/lib/primitives"; +import { Flex, Box, Button } from "src/lib/primitives"; +import { useAuth0 } from "src/lib/auth0"; -export default () => ( - +export default () => { + const { isAuthenticated, loginWithRedirect, logout } = useAuth0(); + + return ( - Billable + + Billable + + {!isAuthenticated && ( + + )} + {isAuthenticated && } + + - -); + ); +}; diff --git a/web/src/lib/auth0/SecureRoute.js b/web/src/lib/auth0/SecureRoute.js new file mode 100644 index 000000000000..6b59f7a65373 --- /dev/null +++ b/web/src/lib/auth0/SecureRoute.js @@ -0,0 +1,23 @@ +import { useEffect } from "react"; +import { Route } from "react-router-dom"; + +import { useAuth0 } from "./"; + +const SecureRoute = ({ path, ...rest }) => { + const { isAuthenticated, loginWithRedirect } = useAuth0(); + + useEffect(() => { + const fn = async () => { + if (!isAuthenticated) { + await loginWithRedirect({ + appState: { targetUrl: path } + }); + } + }; + fn(); + }, [isAuthenticated, loginWithRedirect, path]); + + return ; +}; + +export default SecureRoute; diff --git a/web/src/lib/auth0/auth0.js b/web/src/lib/auth0/auth0.js new file mode 100644 index 000000000000..0eb491f1a5dd --- /dev/null +++ b/web/src/lib/auth0/auth0.js @@ -0,0 +1,89 @@ +import createAuth0Client from "@auth0/auth0-spa-js"; +import { useState, useEffect, useContext } from "react"; + +const DEFAULT_REDIRECT_CALLBACK = () => + window.history.replaceState({}, document.title, window.location.pathname); + +export const Auth0Context = React.createContext(); +export const useAuth0 = () => useContext(Auth0Context); + +export const Auth0Provider = ({ + children, + onRedirectCallback = DEFAULT_REDIRECT_CALLBACK, + ...initOptions +}) => { + const [isAuthenticated, setIsAuthenticated] = useState(); + const [user, setUser] = useState(); + const [auth0Client, setAuth0] = useState(); + const [loading, setLoading] = useState(true); + const [popupOpen, setPopupOpen] = useState(false); + + useEffect(() => { + const initAuth0 = async () => { + const auth0FromHook = await createAuth0Client(initOptions); + setAuth0(auth0FromHook); + + if (window.location.search.includes("code=")) { + const { appState } = await auth0FromHook.handleRedirectCallback(); + onRedirectCallback(appState); + } + + const isAuthenticated = await auth0FromHook.isAuthenticated(); + + setIsAuthenticated(isAuthenticated); + + if (isAuthenticated) { + const user = await auth0FromHook.getUser(); + setUser(user); + } + + setLoading(false); + }; + initAuth0(); + // eslint-disable-next-line + }, []); + + const loginWithPopup = async (params = {}) => { + setPopupOpen(true); + try { + await auth0Client.loginWithPopup(params); + } catch (error) { + console.error(error); + } finally { + setPopupOpen(false); + } + const user = await auth0Client.getUser(); + setUser(user); + setIsAuthenticated(true); + }; + + const handleRedirectCallback = async () => { + setLoading(true); + await auth0Client.handleRedirectCallback(); + const user = await auth0Client.getUser(); + setLoading(false); + setIsAuthenticated(true); + setUser(user); + }; + return ( + auth0Client.getIdTokenClaims(...p), + loginWithRedirect: (...p) => auth0Client.loginWithRedirect(...p), + getTokenSilently: (...p) => auth0Client.getTokenSilently(...p), + getTokenWithPopup: (...p) => auth0Client.getTokenWithPopup(...p), + logout: (...p) => auth0Client.logout(...p) + }} + > + {children} + + ); +}; + +export { default as SecureRoute } from "./SecureRoute"; diff --git a/web/src/pages/Profile/Profile.js b/web/src/pages/Profile/Profile.js new file mode 100644 index 000000000000..a74ca7854547 --- /dev/null +++ b/web/src/pages/Profile/Profile.js @@ -0,0 +1,23 @@ +import { useAuth0 } from "src/lib/auth0"; + +const Profile = () => { + const { loading, user } = useAuth0(); + + console.log(user); + + if (loading || !user) { + return "Loading..."; + } + + return ( + <> + Profile + +

{user.name}

+

{user.email}

+ {JSON.stringify(user, null, 2)} + + ); +}; + +export default Profile; From d67f8fd127899130287fe946592f3b56b8041b0f Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Sat, 13 Jul 2019 18:34:39 +0200 Subject: [PATCH 07/14] Reorganize web structure. --- web/src/components/AppBar.js | 24 +- web/src/index.js | 23 +- web/src/lib/auth0/Auth0Provider.js | 69 ++++ web/src/lib/auth0/auth0.js | 89 +----- web/src/pages/{Router.js => Routes.js} | 2 + yarn.lock | 425 ++++++++++++++++++++++++- 6 files changed, 517 insertions(+), 115 deletions(-) create mode 100644 web/src/lib/auth0/Auth0Provider.js rename web/src/pages/{Router.js => Routes.js} (84%) diff --git a/web/src/components/AppBar.js b/web/src/components/AppBar.js index f416eeadfb25..e7191d800cf6 100644 --- a/web/src/components/AppBar.js +++ b/web/src/components/AppBar.js @@ -1,5 +1,6 @@ import { Flex, Box, Button } from "src/lib/primitives"; import { useAuth0 } from "src/lib/auth0"; +import { Link } from "react-router-dom"; export default () => { const { isAuthenticated, loginWithRedirect, logout } = useAuth0(); @@ -23,11 +24,28 @@ export default () => { `} > Billable - + {!isAuthenticated && ( - + <> + + + + )} + {isAuthenticated && ( + <> + + )} - {isAuthenticated && } diff --git a/web/src/index.js b/web/src/index.js index bcc056b5bf7e..30b0475da1d3 100644 --- a/web/src/index.js +++ b/web/src/index.js @@ -5,30 +5,21 @@ import { ThemeProvider } from "styled-components"; import { Auth0Provider } from "src/lib/auth0"; import theme from "src/lib/theme"; -import Router from "src/pages/Router"; +import Routes from "src/pages/Routes"; import "./index.css"; -const onRedirectCallback = appState => { - window.history.replaceState( - {}, - document.title, - appState && appState.targetUrl - ? appState.targetUrl - : window.location.pathname - ); -}; - ReactDOM.render( - + , diff --git a/web/src/lib/auth0/Auth0Provider.js b/web/src/lib/auth0/Auth0Provider.js new file mode 100644 index 000000000000..238938a386c7 --- /dev/null +++ b/web/src/lib/auth0/Auth0Provider.js @@ -0,0 +1,69 @@ +import createAuth0Client from "@auth0/auth0-spa-js"; +import { useState, useEffect, useContext } from "react"; + +const DEFAULT_REDIRECT_CALLBACK = () => + window.history.replaceState({}, document.title, window.location.pathname); + +export const Auth0Context = React.createContext(); +export const useAuth0 = () => useContext(Auth0Context); + +export const Auth0Provider = ({ + children, + onRedirectCallback = DEFAULT_REDIRECT_CALLBACK, + config +}) => { + const [isAuthenticated, setIsAuthenticated] = useState(); + const [user, setUser] = useState(); + const [auth0Client, setAuth0] = useState(); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const initAuth0 = async () => { + const auth0FromHook = await createAuth0Client({ + ...config, + redirect_uri: window.location.origin + }); + setAuth0(auth0FromHook); + + if (window.location.search.includes("code=")) { + const { appState } = await auth0FromHook.handleRedirectCallback(); + onRedirectCallback(appState); + } + + const isAuthenticated = await auth0FromHook.isAuthenticated(); + setIsAuthenticated(isAuthenticated); + if (isAuthenticated) { + const user = await auth0FromHook.getUser(); + setUser(user); + } + + setLoading(false); + }; + initAuth0(); + }, []); + + const handleRedirectCallback = async () => { + setLoading(true); + await auth0Client.handleRedirectCallback(); + const user = await auth0Client.getUser(); + setLoading(false); + setIsAuthenticated(true); + setUser(user); + }; + + return ( + auth0Client.loginWithRedirect(...p), + getTokenSilently: (...p) => auth0Client.getTokenSilently(...p), + logout: (...p) => auth0Client.logout(...p) + }} + > + {children} + + ); +}; diff --git a/web/src/lib/auth0/auth0.js b/web/src/lib/auth0/auth0.js index 0eb491f1a5dd..7d78c9157588 100644 --- a/web/src/lib/auth0/auth0.js +++ b/web/src/lib/auth0/auth0.js @@ -1,89 +1,2 @@ -import createAuth0Client from "@auth0/auth0-spa-js"; -import { useState, useEffect, useContext } from "react"; - -const DEFAULT_REDIRECT_CALLBACK = () => - window.history.replaceState({}, document.title, window.location.pathname); - -export const Auth0Context = React.createContext(); -export const useAuth0 = () => useContext(Auth0Context); - -export const Auth0Provider = ({ - children, - onRedirectCallback = DEFAULT_REDIRECT_CALLBACK, - ...initOptions -}) => { - const [isAuthenticated, setIsAuthenticated] = useState(); - const [user, setUser] = useState(); - const [auth0Client, setAuth0] = useState(); - const [loading, setLoading] = useState(true); - const [popupOpen, setPopupOpen] = useState(false); - - useEffect(() => { - const initAuth0 = async () => { - const auth0FromHook = await createAuth0Client(initOptions); - setAuth0(auth0FromHook); - - if (window.location.search.includes("code=")) { - const { appState } = await auth0FromHook.handleRedirectCallback(); - onRedirectCallback(appState); - } - - const isAuthenticated = await auth0FromHook.isAuthenticated(); - - setIsAuthenticated(isAuthenticated); - - if (isAuthenticated) { - const user = await auth0FromHook.getUser(); - setUser(user); - } - - setLoading(false); - }; - initAuth0(); - // eslint-disable-next-line - }, []); - - const loginWithPopup = async (params = {}) => { - setPopupOpen(true); - try { - await auth0Client.loginWithPopup(params); - } catch (error) { - console.error(error); - } finally { - setPopupOpen(false); - } - const user = await auth0Client.getUser(); - setUser(user); - setIsAuthenticated(true); - }; - - const handleRedirectCallback = async () => { - setLoading(true); - await auth0Client.handleRedirectCallback(); - const user = await auth0Client.getUser(); - setLoading(false); - setIsAuthenticated(true); - setUser(user); - }; - return ( - auth0Client.getIdTokenClaims(...p), - loginWithRedirect: (...p) => auth0Client.loginWithRedirect(...p), - getTokenSilently: (...p) => auth0Client.getTokenSilently(...p), - getTokenWithPopup: (...p) => auth0Client.getTokenWithPopup(...p), - logout: (...p) => auth0Client.logout(...p) - }} - > - {children} - - ); -}; - +export { Auth0Provider, useAuth0 } from "./Auth0Provider"; export { default as SecureRoute } from "./SecureRoute"; diff --git a/web/src/pages/Router.js b/web/src/pages/Routes.js similarity index 84% rename from web/src/pages/Router.js rename to web/src/pages/Routes.js index 7e37128f0623..64997750ed40 100644 --- a/web/src/pages/Router.js +++ b/web/src/pages/Routes.js @@ -4,6 +4,7 @@ import { SecureRoute } from "src/lib/auth0"; import InvoicePage from "./InvoicePage"; import Profile from "./Profile"; +import Test from "./Test"; const Router = () => { return ( @@ -11,6 +12,7 @@ const Router = () => { + ); diff --git a/yarn.lock b/yarn.lock index a33f7f8bc559..8011c57a0a29 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1279,6 +1279,16 @@ ajv@^6.1.0: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ajv@^6.5.5: + version "6.10.1" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.1.tgz#ebf8d3af22552df9dd049bfbe50cc2390e823593" + integrity sha512-w1YQaVGNC6t2UCPjEawK/vo/dG8OOrVtUmhBT1uJJYxbl5kU2Tj3v6LGqBcsysN1yhuCStJCCA3GqdvKY8sqXQ== + dependencies: + fast-deep-equal "^2.0.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + ansi-align@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-2.0.0.tgz#c36aeccba563b89ceb556f3690f0b1d9e3547f7f" @@ -1551,6 +1561,18 @@ asn1.js@^4.0.0: inherits "^2.0.1" minimalistic-assert "^1.0.0" +asn1@~0.2.3: + version "0.2.4" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" + integrity sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg== + dependencies: + safer-buffer "~2.1.0" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU= + assert@^1.1.1: version "1.5.0" resolved "https://registry.yarnpkg.com/assert/-/assert-1.5.0.tgz#55c109aaf6e0aefdb3dc4b71240c70bf574b18eb" @@ -1586,11 +1608,16 @@ async-retry@^1.2.1: dependencies: retry "0.12.0" -async@^1.5.2: +async@^1.5.0, async@^1.5.2: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo= +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= + atob@^2.1.1: version "2.1.2" resolved "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" @@ -1603,6 +1630,16 @@ auto-bind@^2.0.0: dependencies: "@types/react" "^16.8.12" +aws-sign2@~0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + integrity sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg= + +aws4@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" + integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ== + babel-loader@^8.0.6: version "8.0.6" resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-8.0.6.tgz#e33bdb6f362b03f4bb141a0c21ab87c501b70dfb" @@ -1679,6 +1716,13 @@ batch@0.6.1: resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" integrity sha1-3DQxT05nkxgJP8dgJyUl+UvyXBY= +bcrypt-pbkdf@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" + integrity sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4= + dependencies: + tweetnacl "^0.14.3" + big.js@^3.1.3: version "3.2.0" resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e" @@ -1847,6 +1891,11 @@ browserslist@^4.6.0, browserslist@^4.6.2: electron-to-chromium "^1.3.164" node-releases "^1.1.23" +buffer-equal-constant-time@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819" + integrity sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk= + buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -1966,6 +2015,11 @@ capture-stack-trace@^1.0.0: resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.1.tgz#a6c0bbe1f38f3aa0b92238ecb6ff42c344d4135d" integrity sha512-mYQLZnx5Qt1JgB1WEiMCf2647plpGeQ2NMR/5L0HNZzGQo4fuSPnK+wjfPnKZV0aiJDgzmWqqkV/g7JD+DW0qw== +caseless@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= + chalk@2.4.2, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" @@ -2104,6 +2158,13 @@ color-name@1.1.3: resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= +combined-stream@^1.0.6, combined-stream@~1.0.6: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + commander@2.17.x: version "2.17.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" @@ -2268,7 +2329,7 @@ core-js@^3.0.0, core-js@^3.0.1, core-js@^3.1.3, core-js@^3.1.4: resolved "https://registry.npmjs.org/core-js/-/core-js-3.1.4.tgz#3a2837fc48e582e1ae25907afcd6cf03b0cc7a07" integrity sha512-YNZN8lt82XIMLnLirj9MhKDFZHalwzzrL9YLt6eb0T5D0EDl4IQ90IGkua8mHbnxNrkj1d8hbdizMc0Qmg1WnQ== -core-util-is@~1.0.0: +core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= @@ -2415,12 +2476,19 @@ cyclist@~0.2.2: resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-0.2.2.tgz#1b33792e11e914a2fd6d6ed6447464444e5fa640" integrity sha1-GzN5LhHpFKL9bW7WRHRkRE5fpkA= +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + integrity sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA= + dependencies: + assert-plus "^1.0.0" + date-now@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b" integrity sha1-6vQ5/U1ISK105cx9vvIAZyueNFs= -debug@2.6.9, debug@^2.2.0, debug@^2.3.3: +debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.9: version "2.6.9" resolved "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== @@ -2511,6 +2579,11 @@ del@^4.1.1: pify "^4.0.1" rimraf "^2.6.3" +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= + delegates@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" @@ -2668,6 +2741,21 @@ duplexify@^3.4.2, duplexify@^3.6.0: readable-stream "^2.0.0" stream-shift "^1.0.0" +ecc-jsbn@~0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" + integrity sha1-OoOpBOVDUyh4dMVkt1SThoSamMk= + dependencies: + jsbn "~0.1.0" + safer-buffer "^2.1.0" + +ecdsa-sig-formatter@1.0.11: + version "1.0.11" + resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz#ae0f0fa2d85045ef14a817daa3ce9acd0489e5bf" + integrity sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ== + dependencies: + safe-buffer "^5.0.1" + ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -2871,6 +2959,16 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2: dependencies: homedir-polyfill "^1.0.1" +express-jwt@^5.3.1: + version "5.3.1" + resolved "https://registry.yarnpkg.com/express-jwt/-/express-jwt-5.3.1.tgz#66f05c7dddb5409c037346a98b88965bb10ea4ae" + integrity sha512-1C9RNq0wMp/JvsH/qZMlg3SIPvKu14YkZ4YYv7gJQ1Vq+Dv8LH9tLKenS5vMNth45gTlEUGx+ycp9IHIlaHP/g== + dependencies: + async "^1.5.0" + express-unless "^0.3.0" + jsonwebtoken "^8.1.0" + lodash.set "^4.0.0" + express-logging@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/express-logging/-/express-logging-1.1.1.tgz#62839618cbab5bb3610f1a1c1485352fe9d26c2a" @@ -2878,6 +2976,11 @@ express-logging@^1.1.1: dependencies: on-headers "^1.0.0" +express-unless@^0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/express-unless/-/express-unless-0.3.1.tgz#2557c146e75beb903e2d247f9b5ba01452696e20" + integrity sha1-JVfBRudb65A+LSR/m1ugFFJpbiA= + express@^4.17.1: version "4.17.1" resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134" @@ -2929,6 +3032,11 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2: assign-symbols "^1.0.0" is-extendable "^1.0.1" +extend@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + extglob@^2.0.4: version "2.0.4" resolved "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" @@ -2943,6 +3051,16 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + integrity sha1-lpGEQOMEGnpBT4xS48V06zw+HgU= + +extsprintf@^1.2.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" + integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= + fast-deep-equal@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" @@ -3077,6 +3195,20 @@ for-in@^1.0.2: resolved "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= + +form-data@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" + integrity sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.6" + mime-types "^2.1.12" + forwarded@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" @@ -3202,6 +3334,13 @@ get-value@^2.0.3, get-value@^2.0.6: resolved "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg= +getpass@^0.1.1: + version "0.1.7" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" + integrity sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo= + dependencies: + assert-plus "^1.0.0" + glob-parent@^3.1.0: version "3.1.0" resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" @@ -3367,6 +3506,19 @@ handle-thing@^2.0.0: resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-2.0.0.tgz#0e039695ff50c93fc288557d696f3c1dc6776754" integrity sha512-d4sze1JNC454Wdo2fkuyzCr6aHcbL6PGGuFAz0Li/NcOm1tCHGnWDRmJP85dh9IhQErTc2svWFEX5xHIOo//kQ== +har-schema@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= + +har-validator@~5.1.0: + version "5.1.3" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.3.tgz#1ef89ebd3e4996557675eed9893110dc350fa080" + integrity sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g== + dependencies: + ajv "^6.5.5" + har-schema "^2.0.0" + has-flag@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -3590,6 +3742,15 @@ http-proxy@^1.17.0: follow-redirects "^1.0.0" requires-port "^1.0.0" +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + integrity sha1-muzZJRFHcvPZW2WmCruPfBj7rOE= + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + https-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" @@ -3968,6 +4129,11 @@ is-symbol@^1.0.2: dependencies: has-symbols "^1.0.0" +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= + is-what@^3.2.3: version "3.2.3" resolved "https://registry.yarnpkg.com/is-what/-/is-what-3.2.3.tgz#50f76f1bd8e56967e15765d1d34302513701997b" @@ -4010,6 +4176,11 @@ isobject@^3.0.0, isobject@^3.0.1: resolved "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= +isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= + iterall@^1.1.3, iterall@^1.2.1, iterall@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.2.2.tgz#92d70deb8028e0c39ff3164fdbf4d8b088130cd7" @@ -4025,6 +4196,11 @@ js-levenshtein@^1.1.3: resolved "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== +jsbn@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= + jsesc@^2.5.1: version "2.5.2" resolved "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" @@ -4045,6 +4221,16 @@ json-schema-traverse@^0.4.1: resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== +json-schema@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + integrity sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM= + +json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= + json3@^3.3.2: version "3.3.3" resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.3.tgz#7fc10e375fc5ae42c4705a5cc0aa6f62be305b81" @@ -4076,6 +4262,61 @@ jsonfile@^4.0.0: optionalDependencies: graceful-fs "^4.1.6" +jsonwebtoken@^8.1.0, jsonwebtoken@^8.5.1: + version "8.5.1" + resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz#00e71e0b8df54c2121a1f26137df2280673bcc0d" + integrity sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w== + dependencies: + jws "^3.2.2" + lodash.includes "^4.3.0" + lodash.isboolean "^3.0.3" + lodash.isinteger "^4.0.4" + lodash.isnumber "^3.0.3" + lodash.isplainobject "^4.0.6" + lodash.isstring "^4.0.1" + lodash.once "^4.0.0" + ms "^2.1.1" + semver "^5.6.0" + +jsprim@^1.2.2: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" + integrity sha1-MT5mvB5cwG5Di8G3SZwuXFastqI= + dependencies: + assert-plus "1.0.0" + extsprintf "1.3.0" + json-schema "0.2.3" + verror "1.10.0" + +jwa@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jwa/-/jwa-1.4.1.tgz#743c32985cb9e98655530d53641b66c8645b039a" + integrity sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA== + dependencies: + buffer-equal-constant-time "1.0.1" + ecdsa-sig-formatter "1.0.11" + safe-buffer "^5.0.1" + +jwks-rsa@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/jwks-rsa/-/jwks-rsa-1.5.1.tgz#05b7f1ba4e9829162e2aa3ab6a79d539416de200" + integrity sha512-FcH0mrrfS/5CDArzw7y4AIsNJ15SkAb8XTmfEnpUDmEsUf/4KfSQifff7hYEyrZuKnhisn4L9Pme4fb/ZoHKqQ== + dependencies: + debug "^2.6.9" + jsonwebtoken "^8.5.1" + limiter "^1.1.4" + lru-memoizer "^1.12.0" + ms "^2.1.1" + request "^2.88.0" + +jws@^3.2.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/jws/-/jws-3.2.2.tgz#001099f3639468c9414000e99995fa52fb478304" + integrity sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA== + dependencies: + jwa "^1.4.1" + safe-buffer "^5.0.1" + kill-port@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/kill-port/-/kill-port-1.5.1.tgz#c567eca95824642aa489c8583a3a7d930a651fbf" @@ -4132,6 +4373,11 @@ leven@2.1.0: resolved "https://registry.yarnpkg.com/leven/-/leven-2.1.0.tgz#c2e7a9f772094dee9d34202ae8acce4687875580" integrity sha1-wuep93IJTe6dNCAq6KzORoeHVYA= +limiter@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/limiter/-/limiter-1.1.4.tgz#87c9c3972d389fdb0ba67a45aadbc5d2f8413bc1" + integrity sha512-XCpr5bElgDI65vVgstP8TWjv6/QKWm9GU5UG0Pr5sLQ3QLo8NVKsioe+Jed5/3vFOe3IQuqE7DKwTvKQkjTHvg== + loader-runner@^2.3.0: version "2.4.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.4.0.tgz#ed47066bfe534d7e84c4c7b9998c2a75607d9357" @@ -4172,6 +4418,51 @@ locate-path@^3.0.0: p-locate "^3.0.0" path-exists "^3.0.0" +lock@~0.1.2: + version "0.1.4" + resolved "https://registry.yarnpkg.com/lock/-/lock-0.1.4.tgz#fec7deaef17e7c3a0a55e1da042803e25d91745d" + integrity sha1-/sfervF+fDoKVeHaBCgD4l2RdF0= + +lodash.includes@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f" + integrity sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8= + +lodash.isboolean@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz#6c2e171db2a257cd96802fd43b01b20d5f5870f6" + integrity sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY= + +lodash.isinteger@^4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz#619c0af3d03f8b04c31f5882840b77b11cd68343" + integrity sha1-YZwK89A/iwTDH1iChAt3sRzWg0M= + +lodash.isnumber@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz#3ce76810c5928d03352301ac287317f11c0b1ffc" + integrity sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w= + +lodash.isplainobject@^4.0.6: + version "4.0.6" + resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" + integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs= + +lodash.isstring@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" + integrity sha1-1SfftUVuynzJu5XV2ur4i6VKVFE= + +lodash.once@^4.0.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" + integrity sha1-DdOXEhPHxW34gJd9UEyI+0cal6w= + +lodash.set@^4.0.0: + version "4.3.2" + resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23" + integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM= + lodash.sortby@^4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" @@ -4187,6 +4478,11 @@ lodash@^4.17.11, lodash@^4.17.3, lodash@^4.17.5: resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== +lodash@^4.17.4: + version "4.17.13" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.13.tgz#0bdc3a6adc873d2f4e0c4bac285df91b64fc7b93" + integrity sha512-vm3/XWXfWtRua0FkUyEHBZy8kCPjErNBT9fJx8Zvs+U6zjqPbTUOpkaoum3O5uiA8sm+yNMHXfYkTUHFoMxFNA== + log-update@^3.0.0: version "3.2.0" resolved "https://registry.npmjs.org/log-update/-/log-update-3.2.0.tgz#719f24293250d65d0165f4e2ec2ed805ff062eec" @@ -4238,6 +4534,24 @@ lru-cache@^5.0.0, lru-cache@^5.1.1: dependencies: yallist "^3.0.2" +lru-cache@~4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.0.2.tgz#1d17679c069cda5d040991a09dbc2c0db377e55e" + integrity sha1-HRdnnAac2l0ECZGgnbwsDbN35V4= + dependencies: + pseudomap "^1.0.1" + yallist "^2.0.0" + +lru-memoizer@^1.12.0: + version "1.13.0" + resolved "https://registry.yarnpkg.com/lru-memoizer/-/lru-memoizer-1.13.0.tgz#1469529911602c13df43bca6730640b96072fac8" + integrity sha512-q0wMolfI7yimhZ36kBAfMLOIuDBpRkieN9do0YPjSzCaiy6r73s8wOEq7Ue/B95VSRbXzfnOr1O1QdJc5UIqaw== + dependencies: + lock "~0.1.2" + lodash "^4.17.4" + lru-cache "~4.0.0" + very-fast-args "^1.1.0" + make-dir@^1.0.0: version "1.3.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" @@ -4362,7 +4676,7 @@ mime-db@1.40.0, "mime-db@>= 1.40.0 < 2": resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.40.0.tgz#a65057e998db090f732a68f6c276d387d4126c32" integrity sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA== -mime-types@~2.1.17, mime-types@~2.1.24: +mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.19, mime-types@~2.1.24: version "2.1.24" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.24.tgz#b6f8d0b3e951efb77dedeca194cff6d16f676f81" integrity sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ== @@ -4743,6 +5057,11 @@ number-is-nan@^1.0.0: resolved "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= +oauth-sign@~0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" + integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== + object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" @@ -5066,6 +5385,11 @@ pbkdf2@^3.0.3: safe-buffer "^5.0.1" sha.js "^2.4.8" +performance-now@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= + pify@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" @@ -5268,11 +5592,16 @@ prr@~1.0.1: resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" integrity sha1-0/wRS6BplaRexok/SEzrHXj19HY= -pseudomap@^1.0.2: +pseudomap@^1.0.1, pseudomap@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= +psl@^1.1.24: + version "1.2.0" + resolved "https://registry.yarnpkg.com/psl/-/psl-1.2.0.tgz#df12b5b1b3a30f51c329eacbdef98f3a6e136dc6" + integrity sha512-GEn74ZffufCmkDDLNcl3uuyF/aSD6exEyh1v/ZSdAomB82t6G9hzJVRx0jBmLDW+VfZqks3aScmMw9DszwUalA== + pstree.remy@^1.1.6: version "1.1.7" resolved "https://registry.yarnpkg.com/pstree.remy/-/pstree.remy-1.1.7.tgz#c76963a28047ed61542dc361aa26ee55a7fa15f3" @@ -5320,7 +5649,7 @@ punycode@1.3.2: resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" integrity sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0= -punycode@^1.2.4: +punycode@^1.2.4, punycode@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" integrity sha1-wNWmOycYgArY4esPpSachN1BhF4= @@ -5335,6 +5664,11 @@ qs@6.7.0, qs@^6.5.1, qs@^6.7.0: resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== +qs@~6.5.2: + version "6.5.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" + integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== + querystring-es3@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" @@ -5619,6 +5953,32 @@ repeat-string@^1.6.1: resolved "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= +request@^2.88.0: + version "2.88.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef" + integrity sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg== + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.8.0" + caseless "~0.12.0" + combined-stream "~1.0.6" + extend "~3.0.2" + forever-agent "~0.6.1" + form-data "~2.3.2" + har-validator "~5.1.0" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.19" + oauth-sign "~0.9.0" + performance-now "^2.1.0" + qs "~6.5.2" + safe-buffer "^5.1.2" + tough-cookie "~2.4.3" + tunnel-agent "^0.6.0" + uuid "^3.3.2" + require-dir@^1.2.0: version "1.2.0" resolved "https://registry.npmjs.org/require-dir/-/require-dir-1.2.0.tgz#0d443b75e96012d3ca749cf19f529a789ae74817" @@ -5743,7 +6103,7 @@ safe-regex@^1.1.0: dependencies: ret "~0.1.10" -"safer-buffer@>= 2.1.2 < 3": +"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: version "2.1.2" resolved "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== @@ -6037,6 +6397,21 @@ split-string@^3.0.1, split-string@^3.0.2: dependencies: extend-shallow "^3.0.0" +sshpk@^1.7.0: + version "1.16.1" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877" + integrity sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg== + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + bcrypt-pbkdf "^1.0.0" + dashdash "^1.12.0" + ecc-jsbn "~0.1.1" + getpass "^0.1.1" + jsbn "~0.1.0" + safer-buffer "^2.0.2" + tweetnacl "~0.14.0" + ssri@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8" @@ -6409,6 +6784,14 @@ touch@^3.1.0: dependencies: nopt "~1.0.10" +tough-cookie@~2.4.3: + version "2.4.3" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781" + integrity sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ== + dependencies: + psl "^1.1.24" + punycode "^1.4.1" + trim-right@^1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" @@ -6438,6 +6821,18 @@ tty-browserify@0.0.0: resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" integrity sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY= +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + integrity sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0= + dependencies: + safe-buffer "^5.0.1" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= + type-is@~1.6.17, type-is@~1.6.18: version "1.6.18" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" @@ -6693,6 +7088,20 @@ vary@~1.1.2: resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= +verror@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" + integrity sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA= + dependencies: + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" + +very-fast-args@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/very-fast-args/-/very-fast-args-1.1.0.tgz#e16d1d1faf8a6e596a246421fd90a77963d0b396" + integrity sha1-4W0dH6+KbllqJGQh/ZCneWPQs5Y= + vm-browserify@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.0.tgz#bd76d6a23323e2ca8ffa12028dc04559c75f9019" @@ -6943,7 +7352,7 @@ xtend@^4.0.0, xtend@~4.0.1: resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== -yallist@^2.1.2: +yallist@^2.0.0, yallist@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= From 1afc67fe5e57cbd84ed05b4adc079c8ae2bee28d Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Sat, 13 Jul 2019 18:35:05 +0200 Subject: [PATCH 08/14] Remove example Help query. --- web/src/components/Help/Help.js | 25 ------------------------ web/src/pages/InvoicePage/InvoicePage.js | 8 -------- 2 files changed, 33 deletions(-) delete mode 100644 web/src/components/Help/Help.js diff --git a/web/src/components/Help/Help.js b/web/src/components/Help/Help.js deleted file mode 100644 index ff19dbecbb11..000000000000 --- a/web/src/components/Help/Help.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * This amazing component does... - */ -const Help = ({ as: Element = "div", refetch, ...rest }) => { - return ; -}; - -Help.propTypes = {}; - -Help.queryProps = { - query: gql` - query HelpView { - help - } - `, - skeleton: undefined, - // TODO: This needs a better name. - // parseData? - // cleanData? - dataToProps: data => { - return { children: data.help }; - } -}; - -export default Help; diff --git a/web/src/pages/InvoicePage/InvoicePage.js b/web/src/pages/InvoicePage/InvoicePage.js index bd0bcfad25c8..ceb813e91a4d 100644 --- a/web/src/pages/InvoicePage/InvoicePage.js +++ b/web/src/pages/InvoicePage/InvoicePage.js @@ -9,7 +9,6 @@ import { LineItems, Summary } from "src/components"; -import Help from "src/components/Help"; const MARGIN_BOTTOM = 5; @@ -52,13 +51,6 @@ const Page = () => { max-width: 800px; `} > - - Example Query Component -
- -
-
-        
         
Date: Sat, 13 Jul 2019 18:36:08 +0200
Subject: [PATCH 09/14] Use token to authenticate API.

---
 api/package.json                        |  2 +
 api/src/functions/graphql.js            |  2 +
 api/src/functions/test.js               | 36 ++++++++++++
 packages/hammer-dev-server/src/index.js | 76 ++++++++++++++-----------
 web/src/pages/Test/Test.js              | 39 +++++++++++++
 5 files changed, 121 insertions(+), 34 deletions(-)
 create mode 100644 api/src/functions/test.js
 create mode 100644 web/src/pages/Test/Test.js

diff --git a/api/package.json b/api/package.json
index ecd72b3feb6a..c3d6396104ab 100644
--- a/api/package.json
+++ b/api/package.json
@@ -5,7 +5,9 @@
   "dependencies": {
     "@hammerframework/hammer-api": "0.0.0",
     "apollo-server-lambda": "^2.6.2",
+    "express-jwt": "^5.3.1",
     "graphql": "^14.3.1",
+    "jwks-rsa": "^1.5.1",
     "nexus": "^0.11.7",
     "require-dir": "^1.2.0"
   },
diff --git a/api/src/functions/graphql.js b/api/src/functions/graphql.js
index 3ff2f848ee36..312c822ae4f9 100644
--- a/api/src/functions/graphql.js
+++ b/api/src/functions/graphql.js
@@ -1,3 +1,5 @@
 import { graphQLServerlessFunction } from "@hammerframework/hammer-api";
 
+export const SERVERLESS_FUNCTION_TYPE = "aws";
+
 export const handler = graphQLServerlessFunction();
diff --git a/api/src/functions/test.js b/api/src/functions/test.js
new file mode 100644
index 000000000000..10654fed5ca8
--- /dev/null
+++ b/api/src/functions/test.js
@@ -0,0 +1,36 @@
+// // https://www.netlify.com/blog/2018/09/13/how-to-run-express.js-apps-with-netlify-functions/
+// // https://github.com/dougmoscrop/serverless-http
+
+import jwt from "express-jwt";
+import jwksRsa from "jwks-rsa";
+
+// Set up Auth0 configuration
+const authConfig = {
+  domain: "p4p8.eu.auth0.com",
+  audience: "BILLABLE_API"
+};
+
+// Define middleware that validates incoming bearer tokens
+// using JWKS from p4p8.eu.auth0.com
+const checkJwt = jwt({
+  secret: jwksRsa.expressJwtSecret({
+    cache: true,
+    rateLimit: true,
+    jwksRequestsPerMinute: 5,
+    jwksUri: `https://${authConfig.domain}/.well-known/jwks.json`
+  }),
+
+  audience: authConfig.audience,
+  issuer: `https://${authConfig.domain}/`,
+  algorithm: ["RS256"]
+});
+
+export const SERVERLESS_FUNCTION_TYPE = "express";
+
+export const handler = (req, res, next) => {
+  checkJwt(req, res, next);
+
+  res.send({
+    msg: "Your Access Token was successfully validated!"
+  });
+};
diff --git a/packages/hammer-dev-server/src/index.js b/packages/hammer-dev-server/src/index.js
index 44ac7288dea3..efb97d083025 100755
--- a/packages/hammer-dev-server/src/index.js
+++ b/packages/hammer-dev-server/src/index.js
@@ -73,7 +73,7 @@ app.all("/", (req, res) => {
   `);
 });
 
-app.all("/:routeName", (req, res) => {
+app.all("/:routeName", (req, res, next) => {
   const { routeName } = req.params;
 
   const lambdaFunction = lambdaFunctions[routeName];
@@ -82,44 +82,52 @@ app.all("/:routeName", (req, res) => {
     return res.sendStatus(404);
   }
 
-  const { handler } = lambdaFunction;
+  // We _really_ only want to support express js type functions, but until then
+  // we have to deal with figuring out who you're trying to target.
+
+  const { handler, SERVERLESS_FUNCTION_TYPE = "aws" } = lambdaFunction;
+
   if (typeof handler !== "function") {
     console.warn(`"${routeName}" does not export a function named "handler"`);
     return res.sendStatus(500);
   }
 
-  const event = {
-    httpMethod: req.method,
-    headers: req.headers,
-    path: req.path,
-    queryStringParameters: qs.parse(req.url.split(/\?(.+)/)[1]),
-    ...parseBody(req.body) // adds `body` and `isBase64Encoded`
-  };
-
-  const handlerCallback = response => (
-    error,
-    { statusCode, body, headers = {} }
-  ) => {
-    // TODO: Deal with errors
-    if (error) {
-      console.log("----------");
-      console.log(error);
-      console.log("----------");
-    }
-
-    Object.keys(headers).forEach(header => {
-      response.setHeader(header, headers[header]);
-    });
-    response.statusCode = statusCode;
-    return response.end(body);
-  };
-
-  // TODO: Add support for promises.
-  handler(
-    event,
-    {}, // TODO: Support context
-    handlerCallback(res)
-  );
+  if (SERVERLESS_FUNCTION_TYPE === "aws") {
+    const event = {
+      httpMethod: req.method,
+      headers: req.headers,
+      path: req.path,
+      queryStringParameters: qs.parse(req.url.split(/\?(.+)/)[1]),
+      ...parseBody(req.body) // adds `body` and `isBase64Encoded`
+    };
+
+    const handlerCallback = response => (
+      error,
+      { statusCode, body, headers = {} }
+    ) => {
+      // TODO: Deal with errors
+      if (error) {
+        console.log("----------");
+        console.log(error);
+        console.log("----------");
+      }
+
+      Object.keys(headers).forEach(header => {
+        response.setHeader(header, headers[header]);
+      });
+      response.statusCode = statusCode;
+      return response.end(body);
+    };
+
+    // TODO: Add support for promises.
+    handler(
+      event,
+      {}, // TODO: Support context
+      handlerCallback(res)
+    );
+  } else if (SERVERLESS_FUNCTION_TYPE === "express") {
+    handler(req, res, next);
+  }
 });
 
 app.listen(PORT, () =>
diff --git a/web/src/pages/Test/Test.js b/web/src/pages/Test/Test.js
new file mode 100644
index 000000000000..4e159aba332a
--- /dev/null
+++ b/web/src/pages/Test/Test.js
@@ -0,0 +1,39 @@
+import { useState } from "react";
+import { useAuth0 } from "src/lib/auth0";
+
+const ExternalApi = () => {
+  const [showResult, setShowResult] = useState(false);
+  const [apiMessage, setApiMessage] = useState("");
+  const { getTokenSilently } = useAuth0();
+
+  const callApi = async () => {
+    try {
+      const token = await getTokenSilently();
+
+      console.log(token);
+
+      const response = await fetch("/.netlify/functions/test", {
+        headers: {
+          Authorization: `Bearer ${token}`
+        }
+      });
+
+      const responseData = await response.json();
+
+      setShowResult(true);
+      setApiMessage(responseData);
+    } catch (error) {
+      console.error(error);
+    }
+  };
+
+  return (
+    <>
+      

External API

+ + {showResult && {JSON.stringify(apiMessage, null, 2)}} + + ); +}; + +export default ExternalApi; From 1eb5b259e8bfc1758125a253d6bd730b18b01b8c Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Sat, 13 Jul 2019 22:48:08 +0200 Subject: [PATCH 10/14] Make secure route auth loading state aware. --- web/src/lib/auth0/SecureRoute.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/web/src/lib/auth0/SecureRoute.js b/web/src/lib/auth0/SecureRoute.js index 6b59f7a65373..577c7c652fe4 100644 --- a/web/src/lib/auth0/SecureRoute.js +++ b/web/src/lib/auth0/SecureRoute.js @@ -1,10 +1,14 @@ -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import { Route } from "react-router-dom"; import { useAuth0 } from "./"; -const SecureRoute = ({ path, ...rest }) => { - const { isAuthenticated, loginWithRedirect } = useAuth0(); +const SecureRoute = ({ component: Component, path, ...rest }) => { + const { + loading: authLoading, + isAuthenticated, + loginWithRedirect + } = useAuth0(); useEffect(() => { const fn = async () => { @@ -14,10 +18,15 @@ const SecureRoute = ({ path, ...rest }) => { }); } }; - fn(); - }, [isAuthenticated, loginWithRedirect, path]); + // wait for loading to complete loading before redirecting + // the user. + !authLoading && fn(); + }, [authLoading, isAuthenticated, loginWithRedirect, path]); - return ; + const render = props => + isAuthenticated === true ? : null; + + return ; }; export default SecureRoute; From c0fabd75e3ddf6dc8ed57abd52da1d7fa85a1fe0 Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Sat, 13 Jul 2019 22:48:19 +0200 Subject: [PATCH 11/14] General cleanup. --- web/src/components/AppBar.js | 6 +----- web/src/index.js | 3 ++- web/src/lib/auth0/Auth0Provider.js | 25 +++++++++++-------------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/web/src/components/AppBar.js b/web/src/components/AppBar.js index e7191d800cf6..d0edb0715115 100644 --- a/web/src/components/AppBar.js +++ b/web/src/components/AppBar.js @@ -34,11 +34,7 @@ export default () => { {!isAuthenticated && ( <> - + )} {isAuthenticated && ( diff --git a/web/src/index.js b/web/src/index.js index 30b0475da1d3..92f9bcc79e0a 100644 --- a/web/src/index.js +++ b/web/src/index.js @@ -16,7 +16,8 @@ ReactDOM.render( config={{ domain: "p4p8.eu.auth0.com", client_id: "b7vN4sVz6yjGrq82ctXJW9NRTvlWzkFU", - audience: "BILLABLE_API" + audience: "BILLABLE_API", + redirect_uri: window.location.origin }} > diff --git a/web/src/lib/auth0/Auth0Provider.js b/web/src/lib/auth0/Auth0Provider.js index 238938a386c7..6bf118ee7c9f 100644 --- a/web/src/lib/auth0/Auth0Provider.js +++ b/web/src/lib/auth0/Auth0Provider.js @@ -1,17 +1,10 @@ -import createAuth0Client from "@auth0/auth0-spa-js"; import { useState, useEffect, useContext } from "react"; - -const DEFAULT_REDIRECT_CALLBACK = () => - window.history.replaceState({}, document.title, window.location.pathname); +import createAuth0Client from "@auth0/auth0-spa-js"; export const Auth0Context = React.createContext(); export const useAuth0 = () => useContext(Auth0Context); -export const Auth0Provider = ({ - children, - onRedirectCallback = DEFAULT_REDIRECT_CALLBACK, - config -}) => { +export const Auth0Provider = ({ children, config }) => { const [isAuthenticated, setIsAuthenticated] = useState(); const [user, setUser] = useState(); const [auth0Client, setAuth0] = useState(); @@ -19,15 +12,18 @@ export const Auth0Provider = ({ useEffect(() => { const initAuth0 = async () => { - const auth0FromHook = await createAuth0Client({ - ...config, - redirect_uri: window.location.origin - }); + const auth0FromHook = await createAuth0Client(config); setAuth0(auth0FromHook); if (window.location.search.includes("code=")) { const { appState } = await auth0FromHook.handleRedirectCallback(); - onRedirectCallback(appState); + window.history.replaceState( + {}, + document.title, + appState && appState.targetUrl + ? appState.targetUrl + : window.location.pathname + ); } const isAuthenticated = await auth0FromHook.isAuthenticated(); @@ -58,6 +54,7 @@ export const Auth0Provider = ({ user, loading, handleRedirectCallback, + getIdTokenClaims: (...p) => auth0Client.getIdTokenClaims(...p), loginWithRedirect: (...p) => auth0Client.loginWithRedirect(...p), getTokenSilently: (...p) => auth0Client.getTokenSilently(...p), logout: (...p) => auth0Client.logout(...p) From ae0e03d993c95cb6d75d40694ea2cd53242d308d Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Sat, 13 Jul 2019 23:19:23 +0200 Subject: [PATCH 12/14] Use dotenv for loading configuration variables. --- web/config/webpack.common.js | 7 +++++++ web/package.json | 1 + web/src/index.js | 6 +++--- yarn.lock | 19 +++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/web/config/webpack.common.js b/web/config/webpack.common.js index 7df73f66b3ba..10807d36ec65 100644 --- a/web/config/webpack.common.js +++ b/web/config/webpack.common.js @@ -3,6 +3,9 @@ const path = require("path"); const webpack = require("webpack"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const DirectoryNamedWebpackPlugin = require("directory-named-webpack-plugin"); +const Dotenv = require("dotenv-webpack"); + +console.log(path.resolve(__dirname, "../../.env")); module.exports = { entry: { @@ -16,6 +19,10 @@ module.exports = { React: "react", PropTypes: "prop-types", gql: ["@hammerframework/hammer-web", "gql"] + }), + new Dotenv({ + // billable base-directory + path: path.resolve(__dirname, "../../.env") }) ], module: { diff --git a/web/package.json b/web/package.json index c753e2a191c3..64f2b6499c63 100644 --- a/web/package.json +++ b/web/package.json @@ -24,6 +24,7 @@ "babel-plugin-styled-components": "^1.10.6", "css-loader": "^3.0.0", "directory-named-webpack-plugin": "^4.0.1", + "dotenv-webpack": "^1.7.0", "file-loader": "^4.0.0", "html-webpack-plugin": "^3.2.0", "style-loader": "^0.23.1", diff --git a/web/src/index.js b/web/src/index.js index 92f9bcc79e0a..dc453e918f3f 100644 --- a/web/src/index.js +++ b/web/src/index.js @@ -14,9 +14,9 @@ ReactDOM.render( diff --git a/yarn.lock b/yarn.lock index 8011c57a0a29..f356dcda4f2f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2726,6 +2726,25 @@ dot-prop@^4.1.0: dependencies: is-obj "^1.0.0" +dotenv-defaults@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/dotenv-defaults/-/dotenv-defaults-1.0.2.tgz#441cf5f067653fca4bbdce9dd3b803f6f84c585d" + integrity sha512-iXFvHtXl/hZPiFj++1hBg4lbKwGM+t/GlvELDnRtOFdjXyWP7mubkVr+eZGWG62kdsbulXAef6v/j6kiWc/xGA== + dependencies: + dotenv "^6.2.0" + +dotenv-webpack@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/dotenv-webpack/-/dotenv-webpack-1.7.0.tgz#4384d8c57ee6f405c296278c14a9f9167856d3a1" + integrity sha512-wwNtOBW/6gLQSkb8p43y0Wts970A3xtNiG/mpwj9MLUhtPCQG6i+/DSXXoNN7fbPCU/vQ7JjwGmgOeGZSSZnsw== + dependencies: + dotenv-defaults "^1.0.2" + +dotenv@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.2.0.tgz#941c0410535d942c8becf28d3f357dbd9d476064" + integrity sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w== + duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" From 7e7ac681cf14fd0793d5fe4bd773ce0532b70b0d Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Sat, 13 Jul 2019 23:35:12 +0200 Subject: [PATCH 13/14] Use same config on the api side. --- README.md | 11 +++++++++++ api/package.json | 1 + api/src/functions/test.js | 9 +++++++-- yarn.lock | 5 +++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 093add60ce9e..55ba5371b35f 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,17 @@ Browse to `http://localhost:8910` to see the web app. Lambda functions run on `yarn hammer generate component MyShinyComponent` will create a component and place it under `web/src/components/MyShinyComponent` +### .ENV + +Auth0 requires a few environmental variables, none of those are private, +so just go ahead and use these: + +``` +AUTH0_DOMAIN=p4p8.eu.auth0.com +AUTH0_CLIENT_ID=b7vN4sVz6yjGrq82ctXJW9NRTvlWzkFU +AUTH0_AUDIENCE=BILLABLE_API +``` + ### Transpiling packages There are a bunch of packages in this repository that will eventually be published diff --git a/api/package.json b/api/package.json index c3d6396104ab..43ba88066539 100644 --- a/api/package.json +++ b/api/package.json @@ -5,6 +5,7 @@ "dependencies": { "@hammerframework/hammer-api": "0.0.0", "apollo-server-lambda": "^2.6.2", + "dotenv": "^8.0.0", "express-jwt": "^5.3.1", "graphql": "^14.3.1", "jwks-rsa": "^1.5.1", diff --git a/api/src/functions/test.js b/api/src/functions/test.js index 10654fed5ca8..f1bb94fb591f 100644 --- a/api/src/functions/test.js +++ b/api/src/functions/test.js @@ -4,10 +4,15 @@ import jwt from "express-jwt"; import jwksRsa from "jwks-rsa"; +import dotenv from "dotenv"; + +// hammer base dir. +dotenv.config("../../.env"); + // Set up Auth0 configuration const authConfig = { - domain: "p4p8.eu.auth0.com", - audience: "BILLABLE_API" + domain: process.env.AUTH0_DOMAIN, + audience: process.env.AUTH0_AUDIENCE }; // Define middleware that validates incoming bearer tokens diff --git a/yarn.lock b/yarn.lock index f356dcda4f2f..be5c82e20e29 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2745,6 +2745,11 @@ dotenv@^6.2.0: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.2.0.tgz#941c0410535d942c8becf28d3f357dbd9d476064" integrity sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w== +dotenv@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.0.0.tgz#ed310c165b4e8a97bb745b0a9d99c31bda566440" + integrity sha512-30xVGqjLjiUOArT4+M5q9sYdvuR4riM6yK9wMcas9Vbp6zZa+ocC9dp6QoftuhTPhFAiLK/0C5Ni2nou/Bk8lg== + duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" From 4f7c675c3613ba069cfc8406a76cddddeefe3f90 Mon Sep 17 00:00:00 2001 From: Peter Pistorius Date: Sat, 13 Jul 2019 23:35:54 +0200 Subject: [PATCH 14/14] Ignore .env. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d55b35ac5331..df26e5f5e47a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ dist yarn-error.log .docz */.env +.env .DS_Store api/failed-*.md