From ad1fa987afbd09658966e2f22d840a39c102dc4e Mon Sep 17 00:00:00 2001 From: Will Morgan Date: Mon, 28 Dec 2020 23:20:57 +0000 Subject: [PATCH 01/19] Start examples revamp --- .gitignore | 1 + demo/.env.example | 3 + demo/Dockerfile | 11 ++ demo/README.md | 6 + demo/src/package.json | 13 ++ demo/src/server.js | 38 ++++++ demo/src/static/index.html | 0 demo/src/yarn.lock | 258 +++++++++++++++++++++++++++++++++++++ 8 files changed, 330 insertions(+) create mode 100644 demo/.env.example create mode 100644 demo/Dockerfile create mode 100644 demo/README.md create mode 100644 demo/src/package.json create mode 100644 demo/src/server.js create mode 100644 demo/src/static/index.html create mode 100644 demo/src/yarn.lock diff --git a/.gitignore b/.gitignore index 9f11b75..7e087fe 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea/ +node_modules diff --git a/demo/.env.example b/demo/.env.example new file mode 100644 index 0000000..3d0ea08 --- /dev/null +++ b/demo/.env.example @@ -0,0 +1,3 @@ +BASE_URL=https://eu.rp.secure.iproov.me +API_KEY= +API_SECRET= diff --git a/demo/Dockerfile b/demo/Dockerfile new file mode 100644 index 0000000..f3cfdd8 --- /dev/null +++ b/demo/Dockerfile @@ -0,0 +1,11 @@ +FROM node:lts-alpine + +WORKDIR /app +ADD src/yarn.lock . +ADD src/package.json . +RUN yarn +ADD src/ . + +EXPOSE 80 + +ENTRYPOINT ["node", "server.js"] diff --git a/demo/README.md b/demo/README.md new file mode 100644 index 0000000..b7659bd --- /dev/null +++ b/demo/README.md @@ -0,0 +1,6 @@ +Run: + +``` +docker build . -t test +docker run --env-file $(pwd)/.env -p 80:80 --rm test +``` diff --git a/demo/src/package.json b/demo/src/package.json new file mode 100644 index 0000000..dd83e9e --- /dev/null +++ b/demo/src/package.json @@ -0,0 +1,13 @@ +{ + "name": "@iproov/web-example", + "version": "1.0.0", + "description": "An example of iProov's Web SDK integration", + "main": "server.js", + "author": "iProov Team", + "license": "GPL", + "private": true, + "type": "module", + "dependencies": { + "@hapi/hapi": "^20.0.3" + } +} diff --git a/demo/src/server.js b/demo/src/server.js new file mode 100644 index 0000000..bb24fe3 --- /dev/null +++ b/demo/src/server.js @@ -0,0 +1,38 @@ +import Hapi from "@hapi/hapi" + +async function init() { + const server = Hapi.server({ + port: 80, + host: '0.0.0.0' + }); + + server.route({ + method: 'GET', + path: '/', + handler: (request, h) => { + return 'Hello World!'; + } + }); + + console.log("Launching example server with config:") + console.dir({ + 'BASE_URL': process.env.BASE_URL, + 'API_KEY': process.env.API_KEY, + }) + + await server.start(); + console.log('Web SDK example running on %s', server.info.uri); +} + +process.on('unhandledRejection', (err) => { + console.log(err); + process.exit(1); +}); + +process.on('SIGINT', () => { + console.log("Bye!") + process.exit(0) +}) + + +init(); diff --git a/demo/src/static/index.html b/demo/src/static/index.html new file mode 100644 index 0000000..e69de29 diff --git a/demo/src/yarn.lock b/demo/src/yarn.lock new file mode 100644 index 0000000..1452701 --- /dev/null +++ b/demo/src/yarn.lock @@ -0,0 +1,258 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@hapi/accept@^5.0.1": + version "5.0.1" + resolved "https://registry.yarnpkg.com/@hapi/accept/-/accept-5.0.1.tgz#068553e867f0f63225a506ed74e899441af53e10" + integrity sha512-fMr4d7zLzsAXo28PRRQPXR1o2Wmu+6z+VY1UzDp0iFo13Twj8WePakwXBiqn3E1aAlTpSNzCXdnnQXFhst8h8Q== + dependencies: + "@hapi/boom" "9.x.x" + "@hapi/hoek" "9.x.x" + +"@hapi/ammo@^5.0.1": + version "5.0.1" + resolved "https://registry.yarnpkg.com/@hapi/ammo/-/ammo-5.0.1.tgz#9d34560f5c214eda563d838c01297387efaab490" + integrity sha512-FbCNwcTbnQP4VYYhLNGZmA76xb2aHg9AMPiy18NZyWMG310P5KdFGyA9v2rm5ujrIny77dEEIkMOwl0Xv+fSSA== + dependencies: + "@hapi/hoek" "9.x.x" + +"@hapi/b64@5.x.x": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@hapi/b64/-/b64-5.0.0.tgz#b8210cbd72f4774985e78569b77e97498d24277d" + integrity sha512-ngu0tSEmrezoiIaNGG6rRvKOUkUuDdf4XTPnONHGYfSGRmDqPZX5oJL6HAdKTo1UQHECbdB4OzhWrfgVppjHUw== + dependencies: + "@hapi/hoek" "9.x.x" + +"@hapi/boom@9.x.x": + version "9.1.1" + resolved "https://registry.yarnpkg.com/@hapi/boom/-/boom-9.1.1.tgz#89e6f0e01637c2a4228da0d113e8157c93677b04" + integrity sha512-VNR8eDbBrOxBgbkddRYIe7+8DZ+vSbV6qlmaN2x7eWjsUjy2VmQgChkOKcVZIeupEZYj+I0dqNg430OhwzagjA== + dependencies: + "@hapi/hoek" "9.x.x" + +"@hapi/bounce@2.x.x": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@hapi/bounce/-/bounce-2.0.0.tgz#e6ef56991c366b1e2738b2cd83b01354d938cf3d" + integrity sha512-JesW92uyzOOyuzJKjoLHM1ThiOvHPOLDHw01YV8yh5nCso7sDwJho1h0Ad2N+E62bZyz46TG3xhAi/78Gsct6A== + dependencies: + "@hapi/boom" "9.x.x" + "@hapi/hoek" "9.x.x" + +"@hapi/bourne@2.x.x": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@hapi/bourne/-/bourne-2.0.0.tgz#5bb2193eb685c0007540ca61d166d4e1edaf918d" + integrity sha512-WEezM1FWztfbzqIUbsDzFRVMxSoLy3HugVcux6KDDtTqzPsLE8NDRHfXvev66aH1i2oOKKar3/XDjbvh/OUBdg== + +"@hapi/call@8.x.x": + version "8.0.1" + resolved "https://registry.yarnpkg.com/@hapi/call/-/call-8.0.1.tgz#9e64cd8ba6128eb5be6e432caaa572b1ed8cd7c0" + integrity sha512-bOff6GTdOnoe5b8oXRV3lwkQSb/LAWylvDMae6RgEWWntd0SHtkYbQukDHKlfaYtVnSAgIavJ0kqszF/AIBb6g== + dependencies: + "@hapi/boom" "9.x.x" + "@hapi/hoek" "9.x.x" + +"@hapi/catbox-memory@5.x.x": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@hapi/catbox-memory/-/catbox-memory-5.0.0.tgz#6c18dad1a80737480d1c33bfbefd5d028deec86d" + integrity sha512-ByuxVJPHNaXwLzbBv4GdTr6ccpe1nG+AfYt+8ftDWEJY7EWBWzD+Klhy5oPTDGzU26pNUh1e7fcYI1ILZRxAXQ== + dependencies: + "@hapi/boom" "9.x.x" + "@hapi/hoek" "9.x.x" + +"@hapi/catbox@^11.1.1": + version "11.1.1" + resolved "https://registry.yarnpkg.com/@hapi/catbox/-/catbox-11.1.1.tgz#d277e2d5023fd69cddb33d05b224ea03065fec0c" + integrity sha512-u/8HvB7dD/6X8hsZIpskSDo4yMKpHxFd7NluoylhGrL6cUfYxdQPnvUp9YU2C6F9hsyBVLGulBd9vBN1ebfXOQ== + dependencies: + "@hapi/boom" "9.x.x" + "@hapi/hoek" "9.x.x" + "@hapi/podium" "4.x.x" + "@hapi/validate" "1.x.x" + +"@hapi/content@^5.0.2": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@hapi/content/-/content-5.0.2.tgz#ae57954761de570392763e64cdd75f074176a804" + integrity sha512-mre4dl1ygd4ZyOH3tiYBrOUBzV7Pu/EOs8VLGf58vtOEECWed8Uuw6B4iR9AN/8uQt42tB04qpVaMyoMQh0oMw== + dependencies: + "@hapi/boom" "9.x.x" + +"@hapi/cryptiles@5.x.x": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@hapi/cryptiles/-/cryptiles-5.1.0.tgz#655de4cbbc052c947f696148c83b187fc2be8f43" + integrity sha512-fo9+d1Ba5/FIoMySfMqPBR/7Pa29J2RsiPrl7bkwo5W5o+AN1dAYQRi4SPrPwwVxVGKjgLOEWrsvt1BonJSfLA== + dependencies: + "@hapi/boom" "9.x.x" + +"@hapi/file@2.x.x": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@hapi/file/-/file-2.0.0.tgz#2ecda37d1ae9d3078a67c13b7da86e8c3237dfb9" + integrity sha512-WSrlgpvEqgPWkI18kkGELEZfXr0bYLtr16iIN4Krh9sRnzBZN6nnWxHFxtsnP684wueEySBbXPDg/WfA9xJdBQ== + +"@hapi/hapi@^20.0.3": + version "20.0.3" + resolved "https://registry.yarnpkg.com/@hapi/hapi/-/hapi-20.0.3.tgz#e72cad460394e6d2c15f9c57abb5d3332dea27e3" + integrity sha512-aqJVHVjoY3phiZsgsGjDRG15CoUNIs1azScqLZDOCZUSKYGTbzPi+K0QP+RUjUJ0m8L9dRuTZ27c8HKxG3wEhA== + dependencies: + "@hapi/accept" "^5.0.1" + "@hapi/ammo" "^5.0.1" + "@hapi/boom" "9.x.x" + "@hapi/bounce" "2.x.x" + "@hapi/call" "8.x.x" + "@hapi/catbox" "^11.1.1" + "@hapi/catbox-memory" "5.x.x" + "@hapi/heavy" "^7.0.1" + "@hapi/hoek" "9.x.x" + "@hapi/mimos" "5.x.x" + "@hapi/podium" "^4.1.1" + "@hapi/shot" "^5.0.1" + "@hapi/somever" "3.x.x" + "@hapi/statehood" "^7.0.3" + "@hapi/subtext" "^7.0.3" + "@hapi/teamwork" "5.x.x" + "@hapi/topo" "5.x.x" + "@hapi/validate" "^1.1.0" + +"@hapi/heavy@^7.0.1": + version "7.0.1" + resolved "https://registry.yarnpkg.com/@hapi/heavy/-/heavy-7.0.1.tgz#73315ae33b6e7682a0906b7a11e8ca70e3045874" + integrity sha512-vJ/vzRQ13MtRzz6Qd4zRHWS3FaUc/5uivV2TIuExGTM9Qk+7Zzqj0e2G7EpE6KztO9SalTbiIkTh7qFKj/33cA== + dependencies: + "@hapi/boom" "9.x.x" + "@hapi/hoek" "9.x.x" + "@hapi/validate" "1.x.x" + +"@hapi/hoek@9.x.x", "@hapi/hoek@^9.0.0", "@hapi/hoek@^9.0.4": + version "9.1.1" + resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.1.1.tgz#9daf5745156fd84b8e9889a2dc721f0c58e894aa" + integrity sha512-CAEbWH7OIur6jEOzaai83jq3FmKmv4PmX1JYfs9IrYcGEVI/lyL1EXJGCj7eFVJ0bg5QR8LMxBlEtA+xKiLpFw== + +"@hapi/iron@6.x.x": + version "6.0.0" + resolved "https://registry.yarnpkg.com/@hapi/iron/-/iron-6.0.0.tgz#ca3f9136cda655bdd6028de0045da0de3d14436f" + integrity sha512-zvGvWDufiTGpTJPG1Y/McN8UqWBu0k/xs/7l++HVU535NLHXsHhy54cfEMdW7EjwKfbBfM9Xy25FmTiobb7Hvw== + dependencies: + "@hapi/b64" "5.x.x" + "@hapi/boom" "9.x.x" + "@hapi/bourne" "2.x.x" + "@hapi/cryptiles" "5.x.x" + "@hapi/hoek" "9.x.x" + +"@hapi/mimos@5.x.x": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@hapi/mimos/-/mimos-5.0.0.tgz#245c6c98b1cc2c13395755c730321b913de074eb" + integrity sha512-EVS6wJYeE73InTlPWt+2e3Izn319iIvffDreci3qDNT+t3lA5ylJ0/SoTaID8e0TPNUkHUSsgJZXEmLHvoYzrA== + dependencies: + "@hapi/hoek" "9.x.x" + mime-db "1.x.x" + +"@hapi/nigel@4.x.x": + version "4.0.2" + resolved "https://registry.yarnpkg.com/@hapi/nigel/-/nigel-4.0.2.tgz#8f84ef4bca4fb03b2376463578f253b0b8e863c4" + integrity sha512-ht2KoEsDW22BxQOEkLEJaqfpoKPXxi7tvabXy7B/77eFtOyG5ZEstfZwxHQcqAiZhp58Ae5vkhEqI03kawkYNw== + dependencies: + "@hapi/hoek" "^9.0.4" + "@hapi/vise" "^4.0.0" + +"@hapi/pez@^5.0.1": + version "5.0.3" + resolved "https://registry.yarnpkg.com/@hapi/pez/-/pez-5.0.3.tgz#b75446e6fef8cbb16816573ab7da1b0522e7a2a1" + integrity sha512-mpikYRJjtrbJgdDHG/H9ySqYqwJ+QU/D7FXsYciS9P7NYBXE2ayKDAy3H0ou6CohOCaxPuTV4SZ0D936+VomHA== + dependencies: + "@hapi/b64" "5.x.x" + "@hapi/boom" "9.x.x" + "@hapi/content" "^5.0.2" + "@hapi/hoek" "9.x.x" + "@hapi/nigel" "4.x.x" + +"@hapi/podium@4.x.x", "@hapi/podium@^4.1.1": + version "4.1.1" + resolved "https://registry.yarnpkg.com/@hapi/podium/-/podium-4.1.1.tgz#106e5849f2cb19b8767cc16007e0107f27c3c791" + integrity sha512-jh7a6+5Z4FUWzx8fgmxjaAa1DTBu+Qfg+NbVdo0f++rE5DgsVidUYrLDp3db65+QjDLleA2MfKQXkpT8ylBDXA== + dependencies: + "@hapi/hoek" "9.x.x" + "@hapi/teamwork" "5.x.x" + "@hapi/validate" "1.x.x" + +"@hapi/shot@^5.0.1": + version "5.0.4" + resolved "https://registry.yarnpkg.com/@hapi/shot/-/shot-5.0.4.tgz#6c978314f21a054c041f4becc50095dd78d3d775" + integrity sha512-PcEz0WJgFDA3xNSMeONgQmothFr7jhbbRRSAKaDh7chN7zOXBlhl13bvKZW6CMb2xVfJUmt34CW3e/oExMgBhQ== + dependencies: + "@hapi/hoek" "9.x.x" + "@hapi/validate" "1.x.x" + +"@hapi/somever@3.x.x": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@hapi/somever/-/somever-3.0.0.tgz#f4e9b16a948415b926b4dd898013602b0cb45758" + integrity sha512-Upw/kmKotC9iEmK4y047HMYe4LDKsE5NWfjgX41XNKmFvxsQL7OiaCWVhuyyhU0ShDGBfIAnCH8jZr49z/JzZA== + dependencies: + "@hapi/bounce" "2.x.x" + "@hapi/hoek" "9.x.x" + +"@hapi/statehood@^7.0.3": + version "7.0.3" + resolved "https://registry.yarnpkg.com/@hapi/statehood/-/statehood-7.0.3.tgz#655166f3768344ed3c3b50375a303cdeca8040d9" + integrity sha512-pYB+pyCHkf2Amh67QAXz7e/DN9jcMplIL7Z6N8h0K+ZTy0b404JKPEYkbWHSnDtxLjJB/OtgElxocr2fMH4G7w== + dependencies: + "@hapi/boom" "9.x.x" + "@hapi/bounce" "2.x.x" + "@hapi/bourne" "2.x.x" + "@hapi/cryptiles" "5.x.x" + "@hapi/hoek" "9.x.x" + "@hapi/iron" "6.x.x" + "@hapi/validate" "1.x.x" + +"@hapi/subtext@^7.0.3": + version "7.0.3" + resolved "https://registry.yarnpkg.com/@hapi/subtext/-/subtext-7.0.3.tgz#f7440fc7c966858e1f39681e99eb6171c71e7abd" + integrity sha512-CekDizZkDGERJ01C0+TzHlKtqdXZxzSWTOaH6THBrbOHnsr3GY+yiMZC+AfNCypfE17RaIakGIAbpL2Tk1z2+A== + dependencies: + "@hapi/boom" "9.x.x" + "@hapi/bourne" "2.x.x" + "@hapi/content" "^5.0.2" + "@hapi/file" "2.x.x" + "@hapi/hoek" "9.x.x" + "@hapi/pez" "^5.0.1" + "@hapi/wreck" "17.x.x" + +"@hapi/teamwork@5.x.x": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@hapi/teamwork/-/teamwork-5.1.0.tgz#7801a61fc727f702fd2196ef7625eb4e389f4124" + integrity sha512-llqoQTrAJDTXxG3c4Kz/uzhBS1TsmSBa/XG5SPcVXgmffHE1nFtyLIK0hNJHCB3EuBKT84adzd1hZNY9GJLWtg== + +"@hapi/topo@5.x.x", "@hapi/topo@^5.0.0": + version "5.0.0" + resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.0.0.tgz#c19af8577fa393a06e9c77b60995af959be721e7" + integrity sha512-tFJlT47db0kMqVm3H4nQYgn6Pwg10GTZHb1pwmSiv1K4ks6drQOtfEF5ZnPjkvC+y4/bUPHK+bc87QvLcL+WMw== + dependencies: + "@hapi/hoek" "^9.0.0" + +"@hapi/validate@1.x.x", "@hapi/validate@^1.1.0": + version "1.1.3" + resolved "https://registry.yarnpkg.com/@hapi/validate/-/validate-1.1.3.tgz#f750a07283929e09b51aa16be34affb44e1931ad" + integrity sha512-/XMR0N0wjw0Twzq2pQOzPBZlDzkekGcoCtzO314BpIEsbXdYGthQUbxgkGDf4nhk1+IPDAsXqWjMohRQYO06UA== + dependencies: + "@hapi/hoek" "^9.0.0" + "@hapi/topo" "^5.0.0" + +"@hapi/vise@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@hapi/vise/-/vise-4.0.0.tgz#c6a94fe121b94a53bf99e7489f7fcc74c104db02" + integrity sha512-eYyLkuUiFZTer59h+SGy7hUm+qE9p+UemePTHLlIWppEd+wExn3Df5jO04bFQTm7nleF5V8CtuYQYb+VFpZ6Sg== + dependencies: + "@hapi/hoek" "9.x.x" + +"@hapi/wreck@17.x.x": + version "17.1.0" + resolved "https://registry.yarnpkg.com/@hapi/wreck/-/wreck-17.1.0.tgz#fbdc380c6f3fa1f8052dc612b2d3b6ce3e88dbec" + integrity sha512-nx6sFyfqOpJ+EFrHX+XWwJAxs3ju4iHdbB/bwR8yTNZOiYmuhA8eCe7lYPtYmb4j7vyK/SlbaQsmTtUrMvPEBw== + dependencies: + "@hapi/boom" "9.x.x" + "@hapi/bourne" "2.x.x" + "@hapi/hoek" "9.x.x" + +mime-db@1.x.x: + version "1.45.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.45.0.tgz#cceeda21ccd7c3a745eba2decd55d4b73e7879ea" + integrity sha512-CkqLUxUk15hofLoLyljJSrukZi8mAtgd+yE5uO4tqRZsdsAJKv0O+rFMhVDRJgozy+yG6md5KwuXhD4ocIoP+w== From 295205f65848184a09d0397be08474d7d4fd0d94 Mon Sep 17 00:00:00 2001 From: Will Morgan Date: Tue, 29 Dec 2020 07:56:21 +0000 Subject: [PATCH 02/19] Add H5BP --- demo/.prettierrc | 9 + demo/package.json | 5 + demo/src/server.js | 59 +- demo/src/static/.editorconfig | 10 + demo/src/static/.gitattributes | 194 + demo/src/static/.htaccess | 1225 +++ demo/src/static/404.html | 62 + demo/src/static/LICENSE.txt | 19 + demo/src/static/css/main.css | 263 + demo/src/static/css/normalize.css | 349 + demo/src/static/favicon.ico | Bin 0 -> 766 bytes demo/src/static/icon.png | Bin 0 -> 4029 bytes demo/src/static/index.html | 41 + demo/src/static/js/main.js | 0 demo/src/static/js/plugins.js | 24 + .../static/js/vendor/modernizr-3.11.2.min.js | 3 + demo/src/static/package-lock.json | 7450 +++++++++++++++++ demo/src/static/package.json | 17 + demo/src/static/robots.txt | 5 + demo/src/static/site.webmanifest | 12 + demo/src/static/tile-wide.png | Bin 0 -> 1854 bytes demo/src/static/tile.png | Bin 0 -> 3482 bytes demo/yarn.lock | 8 + 23 files changed, 9725 insertions(+), 30 deletions(-) create mode 100644 demo/.prettierrc create mode 100644 demo/package.json create mode 100644 demo/src/static/.editorconfig create mode 100644 demo/src/static/.gitattributes create mode 100644 demo/src/static/.htaccess create mode 100644 demo/src/static/404.html create mode 100644 demo/src/static/LICENSE.txt create mode 100644 demo/src/static/css/main.css create mode 100644 demo/src/static/css/normalize.css create mode 100644 demo/src/static/favicon.ico create mode 100644 demo/src/static/icon.png create mode 100644 demo/src/static/js/main.js create mode 100644 demo/src/static/js/plugins.js create mode 100644 demo/src/static/js/vendor/modernizr-3.11.2.min.js create mode 100644 demo/src/static/package-lock.json create mode 100644 demo/src/static/package.json create mode 100644 demo/src/static/robots.txt create mode 100644 demo/src/static/site.webmanifest create mode 100644 demo/src/static/tile-wide.png create mode 100644 demo/src/static/tile.png create mode 100644 demo/yarn.lock diff --git a/demo/.prettierrc b/demo/.prettierrc new file mode 100644 index 0000000..0d126be --- /dev/null +++ b/demo/.prettierrc @@ -0,0 +1,9 @@ +{ + "bracketSpacing": true, + "printWidth": 120, + "quoteProps": "consistent", + "semi": false, + "singleQuote": false, + "trailingComma": "es5", + "tabWidth": 2 +} diff --git a/demo/package.json b/demo/package.json new file mode 100644 index 0000000..15a79db --- /dev/null +++ b/demo/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "prettier": "^2.2.1" + } +} diff --git a/demo/src/server.js b/demo/src/server.js index bb24fe3..17724f8 100644 --- a/demo/src/server.js +++ b/demo/src/server.js @@ -1,38 +1,37 @@ import Hapi from "@hapi/hapi" async function init() { - const server = Hapi.server({ - port: 80, - host: '0.0.0.0' - }); - - server.route({ - method: 'GET', - path: '/', - handler: (request, h) => { - return 'Hello World!'; - } - }); - - console.log("Launching example server with config:") - console.dir({ - 'BASE_URL': process.env.BASE_URL, - 'API_KEY': process.env.API_KEY, - }) - - await server.start(); - console.log('Web SDK example running on %s', server.info.uri); + const server = Hapi.server({ + port: 80, + host: "0.0.0.0", + }) + + server.route({ + method: "GET", + path: "/", + handler: (request, h) => { + return "Hello World!" + }, + }) + + console.log("Launching example server with config:") + console.dir({ + BASE_URL: process.env.BASE_URL, + API_KEY: process.env.API_KEY, + }) + + await server.start() + console.log("Web SDK example running on %s", server.info.uri) } -process.on('unhandledRejection', (err) => { - console.log(err); - process.exit(1); -}); - -process.on('SIGINT', () => { - console.log("Bye!") - process.exit(0) +process.on("unhandledRejection", (err) => { + console.log(err) + process.exit(1) }) +process.on("SIGINT", () => { + console.log("Bye!") + process.exit(0) +}) -init(); +init() diff --git a/demo/src/static/.editorconfig b/demo/src/static/.editorconfig new file mode 100644 index 0000000..6cee539 --- /dev/null +++ b/demo/src/static/.editorconfig @@ -0,0 +1,10 @@ +# editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/demo/src/static/.gitattributes b/demo/src/static/.gitattributes new file mode 100644 index 0000000..c664a90 --- /dev/null +++ b/demo/src/static/.gitattributes @@ -0,0 +1,194 @@ +## GITATTRIBUTES FOR WEB PROJECTS +# +# These settings are for any web project. +# +# Details per file setting: +# text These files should be normalized (i.e. convert CRLF to LF). +# binary These files are binary and should be left untouched. +# +# Note that binary is a macro for -text -diff. +###################################################################### + +## AUTO-DETECT +## Handle line endings automatically for files detected as +## text and leave all files detected as binary untouched. +## This will handle all files NOT defined below. +* text=auto + +## SOURCE CODE +*.bat text eol=crlf +*.coffee text +*.css text +*.htm text +*.html text +*.inc text +*.ini text +*.js text +*.json text +*.jsx text +*.less text +*.od text +*.onlydata text +*.php text +*.pl text +*.py text +*.rb text +*.sass text +*.scm text +*.scss text +*.sh text eol=lf +*.sql text +*.styl text +*.tag text +*.ts text +*.tsx text +*.xml text +*.xhtml text + +## DOCKER +*.dockerignore text +Dockerfile text + +## DOCUMENTATION +*.markdown text +*.md text +*.mdwn text +*.mdown text +*.mkd text +*.mkdn text +*.mdtxt text +*.mdtext text +*.txt text +AUTHORS text +CHANGELOG text +CHANGES text +CONTRIBUTING text +COPYING text +copyright text +*COPYRIGHT* text +INSTALL text +license text +LICENSE text +NEWS text +readme text +*README* text +TODO text + +## TEMPLATES +*.dot text +*.ejs text +*.haml text +*.handlebars text +*.hbs text +*.hbt text +*.jade text +*.latte text +*.mustache text +*.njk text +*.phtml text +*.tmpl text +*.tpl text +*.twig text + +## LINTERS +.babelrc text +.csslintrc text +.eslintrc text +.htmlhintrc text +.jscsrc text +.jshintrc text +.jshintignore text +.prettierrc text +.stylelintrc text + +## CONFIGS +*.bowerrc text +*.cnf text +*.conf text +*.config text +.browserslistrc text +.editorconfig text +.gitattributes text +.gitconfig text +.gitignore text +.htaccess text +*.npmignore text +*.yaml text +*.yml text +browserslist text +Makefile text +makefile text + +## HEROKU +Procfile text +.slugignore text + +## GRAPHICS +*.ai binary +*.bmp binary +*.eps binary +*.gif binary +*.ico binary +*.jng binary +*.jp2 binary +*.jpg binary +*.jpeg binary +*.jpx binary +*.jxr binary +*.pdf binary +*.png binary +*.psb binary +*.psd binary +*.svg text +*.svgz binary +*.tif binary +*.tiff binary +*.wbmp binary +*.webp binary + +## AUDIO +*.kar binary +*.m4a binary +*.mid binary +*.midi binary +*.mp3 binary +*.ogg binary +*.ra binary + +## VIDEO +*.3gpp binary +*.3gp binary +*.as binary +*.asf binary +*.asx binary +*.fla binary +*.flv binary +*.m4v binary +*.mng binary +*.mov binary +*.mp4 binary +*.mpeg binary +*.mpg binary +*.ogv binary +*.swc binary +*.swf binary +*.webm binary + +## ARCHIVES +*.7z binary +*.gz binary +*.jar binary +*.rar binary +*.tar binary +*.zip binary + +## FONTS +*.ttf binary +*.eot binary +*.otf binary +*.woff binary +*.woff2 binary + +## EXECUTABLES +*.exe binary +*.pyc binary diff --git a/demo/src/static/.htaccess b/demo/src/static/.htaccess new file mode 100644 index 0000000..12a2e0a --- /dev/null +++ b/demo/src/static/.htaccess @@ -0,0 +1,1225 @@ +# Apache Server Configs v4.0.0 | MIT License +# https://github.com/h5bp/server-configs-apache + +# (!) Using `.htaccess` files slows down Apache, therefore, if you have +# access to the main server configuration file (which is usually called +# `httpd.conf`), you should add this logic there. +# +# https://httpd.apache.org/docs/current/howto/htaccess.html + +# ###################################################################### +# # CROSS-ORIGIN # +# ###################################################################### + +# ---------------------------------------------------------------------- +# | Cross-origin requests | +# ---------------------------------------------------------------------- + +# Allow cross-origin requests. +# +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS +# https://enable-cors.org/ +# https://www.w3.org/TR/cors/ + +# (!) Do not use this without understanding the consequences. +# This will permit access from any other website. +# Instead of using this file, consider using a specific rule such as +# allowing access based on (sub)domain: +# +# Header set Access-Control-Allow-Origin "subdomain.example.com" + +# +# Header set Access-Control-Allow-Origin "*" +# + +# ---------------------------------------------------------------------- +# | Cross-origin images | +# ---------------------------------------------------------------------- + +# Send the CORS header for images when browsers request it. +# +# https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image +# https://blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html + + + + + SetEnvIf Origin ":" IS_CORS + Header set Access-Control-Allow-Origin "*" env=IS_CORS + + + + +# ---------------------------------------------------------------------- +# | Cross-origin web fonts | +# ---------------------------------------------------------------------- + +# Allow cross-origin access to web fonts. +# +# https://developers.google.com/fonts/docs/troubleshooting + + + + Header set Access-Control-Allow-Origin "*" + + + +# ---------------------------------------------------------------------- +# | Cross-origin resource timing | +# ---------------------------------------------------------------------- + +# Allow cross-origin access to the timing information for all resources. +# +# If a resource isn't served with a `Timing-Allow-Origin` header that would +# allow its timing information to be shared with the document, some of the +# attributes of the `PerformanceResourceTiming` object will be set to zero. +# +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Timing-Allow-Origin +# https://www.w3.org/TR/resource-timing/ +# https://www.stevesouders.com/blog/2014/08/21/resource-timing-practical-tips/ + +# +# Header set Timing-Allow-Origin: "*" +# + +# ###################################################################### +# # ERRORS # +# ###################################################################### + +# ---------------------------------------------------------------------- +# | Custom error messages/pages | +# ---------------------------------------------------------------------- + +# Customize what Apache returns to the client in case of an error. +# +# https://httpd.apache.org/docs/current/mod/core.html#errordocument + +ErrorDocument 404 /404.html + +# ---------------------------------------------------------------------- +# | Error prevention | +# ---------------------------------------------------------------------- + +# Disable the pattern matching based on filenames. +# +# This setting prevents Apache from returning a 404 error as the result of a +# rewrite when the directory with the same name does not exist. +# +# https://httpd.apache.org/docs/current/content-negotiation.html#multiviews + +Options -MultiViews + +# ###################################################################### +# # INTERNET EXPLORER # +# ###################################################################### + +# ---------------------------------------------------------------------- +# | Document modes | +# ---------------------------------------------------------------------- + +# Force Internet Explorer 8/9/10 to render pages in the highest mode +# available in various cases when it may not. +# +# https://hsivonen.fi/doctype/#ie8 +# +# (!) Starting with Internet Explorer 11, document modes are deprecated. +# If your business still relies on older web apps and services that were +# designed for older versions of Internet Explorer, you might want to +# consider enabling `Enterprise Mode` throughout your company. +# +# https://msdn.microsoft.com/en-us/library/ie/bg182625.aspx#docmode +# https://blogs.msdn.microsoft.com/ie/2014/04/02/stay-up-to-date-with-enterprise-mode-for-internet-explorer-11/ +# https://msdn.microsoft.com/en-us/library/ff955275.aspx + + + Header always set X-UA-Compatible "IE=edge" "expr=%{CONTENT_TYPE} =~ m#text/html#i" + + +# ###################################################################### +# # MEDIA TYPES AND CHARACTER ENCODINGS # +# ###################################################################### + +# ---------------------------------------------------------------------- +# | Media types | +# ---------------------------------------------------------------------- + +# Serve resources with the proper media types (f.k.a. MIME types). +# +# https://www.iana.org/assignments/media-types/media-types.xhtml +# https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype + + + + # Data interchange + + AddType application/atom+xml atom + AddType application/json json map topojson + AddType application/ld+json jsonld + AddType application/rss+xml rss + AddType application/geo+json geojson + AddType application/rdf+xml rdf + AddType application/xml xml + + + # JavaScript + + # Servers should use text/javascript for JavaScript resources. + # https://html.spec.whatwg.org/multipage/scripting.html#scriptingLanguages + + AddType text/javascript js mjs + + + # Manifest files + + AddType application/manifest+json webmanifest + AddType application/x-web-app-manifest+json webapp + AddType text/cache-manifest appcache + + + # Media files + + AddType audio/mp4 f4a f4b m4a + AddType audio/ogg oga ogg opus + AddType image/bmp bmp + AddType image/svg+xml svg svgz + AddType image/webp webp + AddType video/mp4 f4v f4p m4v mp4 + AddType video/ogg ogv + AddType video/webm webm + AddType video/x-flv flv + + # Serving `.ico` image files with a different media type prevents + # Internet Explorer from displaying them as images: + # https://github.com/h5bp/html5-boilerplate/commit/37b5fec090d00f38de64b591bcddcb205aadf8ee + + AddType image/x-icon cur ico + + + # WebAssembly + + AddType application/wasm wasm + + + # Web fonts + + AddType font/woff woff + AddType font/woff2 woff2 + AddType application/vnd.ms-fontobject eot + AddType font/ttf ttf + AddType font/collection ttc + AddType font/otf otf + + + # Other + + AddType application/octet-stream safariextz + AddType application/x-bb-appworld bbaw + AddType application/x-chrome-extension crx + AddType application/x-opera-extension oex + AddType application/x-xpinstall xpi + AddType text/calendar ics + AddType text/markdown markdown md + AddType text/vcard vcard vcf + AddType text/vnd.rim.location.xloc xloc + AddType text/vtt vtt + AddType text/x-component htc + + + +# ---------------------------------------------------------------------- +# | Character encodings | +# ---------------------------------------------------------------------- + +# Serve all resources labeled as `text/html` or `text/plain` with the media type +# `charset` parameter set to `UTF-8`. +# +# https://httpd.apache.org/docs/current/mod/core.html#adddefaultcharset + +AddDefaultCharset utf-8 + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Serve the following file types with the media type `charset` parameter set to +# `UTF-8`. +# +# https://httpd.apache.org/docs/current/mod/mod_mime.html#addcharset + + + AddCharset utf-8 .appcache \ + .bbaw \ + .css \ + .htc \ + .ics \ + .js \ + .json \ + .manifest \ + .map \ + .markdown \ + .md \ + .mjs \ + .topojson \ + .vtt \ + .vcard \ + .vcf \ + .webmanifest \ + .xloc + + +# ###################################################################### +# # REWRITES # +# ###################################################################### + +# ---------------------------------------------------------------------- +# | Rewrite engine | +# ---------------------------------------------------------------------- + +# (1) Turn on the rewrite engine (this is necessary in order for the +# `RewriteRule` directives to work). +# +# https://httpd.apache.org/docs/current/mod/mod_rewrite.html#RewriteEngine +# +# (2) Enable the `FollowSymLinks` option if it isn't already. +# +# https://httpd.apache.org/docs/current/mod/core.html#options +# +# (3) If your web host doesn't allow the `FollowSymlinks` option, you need to +# comment it out or remove it, and then uncomment the +# `Options +SymLinksIfOwnerMatch` line (4), but be aware of the performance +# impact. +# +# https://httpd.apache.org/docs/current/misc/perf-tuning.html#symlinks +# +# (4) Some cloud hosting services will require you set `RewriteBase`. +# +# https://www.rackspace.com/knowledge_center/frequently-asked-question/why-is-modrewrite-not-working-on-my-site +# https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase +# +# (5) Depending on how your server is set up, you may also need to use the +# `RewriteOptions` directive to enable some options for the rewrite engine. +# +# https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriteoptions + + + + # (1) + RewriteEngine On + + # (2) + Options +FollowSymlinks + + # (3) + # Options +SymLinksIfOwnerMatch + + # (4) + # RewriteBase / + + # (5) + # RewriteOptions + + + +# ---------------------------------------------------------------------- +# | Forcing `https://` | +# ---------------------------------------------------------------------- + +# Redirect from the `http://` to the `https://` version of the URL. +# +# https://wiki.apache.org/httpd/RewriteHTTPToHTTPS + +# (1) If you're using cPanel AutoSSL or the Let's Encrypt webroot method it +# will fail to validate the certificate if validation requests are +# redirected to HTTPS. Turn on the condition(s) you need. +# +# https://www.iana.org/assignments/well-known-uris/well-known-uris.xhtml +# https://tools.ietf.org/html/draft-ietf-acme-acme-12 + +# +# RewriteEngine On +# RewriteCond %{HTTPS} !=on +# # (1) +# # RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/ +# # RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[\w-]+$ +# # RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ +# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] +# + +# ---------------------------------------------------------------------- +# | Suppressing the `www.` at the beginning of URLs | +# ---------------------------------------------------------------------- + +# Rewrite www.example.com → example.com + +# The same content should never be available under two different URLs, +# especially not with and without `www.` at the beginning. +# This can cause SEO problems (duplicate content), and therefore, you should +# choose one of the alternatives and redirect the other one. +# +# (!) NEVER USE BOTH WWW-RELATED RULES AT THE SAME TIME! + +# (1) Set %{ENV:PROTO} variable, to allow rewrites to redirect with the +# appropriate schema automatically (http or https). +# +# (2) The rule assumes by default that both HTTP and HTTPS environments are +# available for redirection. +# If your SSL certificate could not handle one of the domains used during +# redirection, you should turn the condition on. +# +# https://github.com/h5bp/server-configs-apache/issues/52 + + + + RewriteEngine On + + # (1) + RewriteCond %{HTTPS} =on + RewriteRule ^ - [E=PROTO:https] + RewriteCond %{HTTPS} !=on + RewriteRule ^ - [E=PROTO:http] + + # (2) + # RewriteCond %{HTTPS} !=on + + RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] + RewriteRule ^ %{ENV:PROTO}://%1%{REQUEST_URI} [R=301,L] + + + +# ---------------------------------------------------------------------- +# | Forcing the `www.` at the beginning of URLs | +# ---------------------------------------------------------------------- + +# Rewrite example.com → www.example.com + +# The same content should never be available under two different URLs, +# especially not with and without `www.` at the beginning. +# This can cause SEO problems (duplicate content), and therefore, you should +# choose one of the alternatives and redirect the other one. +# +# (!) NEVER USE BOTH WWW-RELATED RULES AT THE SAME TIME! + +# (1) Set %{ENV:PROTO} variable, to allow rewrites to redirect with the +# appropriate schema automatically (http or https). +# +# (2) The rule assumes by default that both HTTP and HTTPS environments are +# available for redirection. +# If your SSL certificate could not handle one of the domains used during +# redirection, you should turn the condition on. +# +# https://github.com/h5bp/server-configs-apache/issues/52 + +# Be aware that the following might not be a good idea if you use "real" +# subdomains for certain parts of your website. + +# + +# RewriteEngine On + +# # (1) +# RewriteCond %{HTTPS} =on +# RewriteRule ^ - [E=PROTO:https] +# RewriteCond %{HTTPS} !=on +# RewriteRule ^ - [E=PROTO:http] + +# # (2) +# # RewriteCond %{HTTPS} !=on + +# RewriteCond %{HTTP_HOST} !^www\. [NC] +# RewriteCond %{SERVER_ADDR} !=127.0.0.1 +# RewriteCond %{SERVER_ADDR} !=::1 +# RewriteRule ^ %{ENV:PROTO}://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] + +# + +# ###################################################################### +# # SECURITY # +# ###################################################################### + +# ---------------------------------------------------------------------- +# | Frame Options | +# ---------------------------------------------------------------------- + +# Protect website against clickjacking. +# +# The example below sends the `X-Frame-Options` response header with the value +# `DENY`, informing browsers not to display the content of the web page in any +# frame. +# +# This might not be the best setting for everyone. You should read about the +# other two possible values the `X-Frame-Options` header field can have: +# `SAMEORIGIN` and `ALLOW-FROM`. +# https://tools.ietf.org/html/rfc7034#section-2.1. +# +# Keep in mind that while you could send the `X-Frame-Options` header for all +# of your website's pages, this has the potential downside that it forbids even +# non-malicious framing of your content (e.g.: when users visit your website +# using a Google Image Search results page). +# +# Nonetheless, you should ensure that you send the `X-Frame-Options` header for +# all pages that allow a user to make a state-changing operation (e.g: pages +# that contain one-click purchase links, checkout or bank-transfer confirmation +# pages, pages that make permanent configuration changes, etc.). +# +# Sending the `X-Frame-Options` header can also protect your website against +# more than just clickjacking attacks. +# https://cure53.de/xfo-clickjacking.pdf. +# +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options +# https://tools.ietf.org/html/rfc7034 +# https://blogs.msdn.microsoft.com/ieinternals/2010/03/30/combating-clickjacking-with-x-frame-options/ +# https://www.owasp.org/index.php/Clickjacking + +# +# Header always set X-Frame-Options "DENY" "expr=%{CONTENT_TYPE} =~ m#text/html#i" +# + +# ---------------------------------------------------------------------- +# | Content Security Policy (CSP) | +# ---------------------------------------------------------------------- + +# Mitigate the risk of cross-site scripting and other content-injection +# attacks. +# +# This can be done by setting a `Content Security Policy` which whitelists +# trusted sources of content for your website. +# +# There is no policy that fits all websites, you will have to modify the +# `Content-Security-Policy` directives in the example depending on your needs. +# +# The example policy below aims to: +# +# (1) Restrict all fetches by default to the origin of the current website by +# setting the `default-src` directive to `'self'` - which acts as a +# fallback to all "Fetch directives" (https://developer.mozilla.org/en-US/docs/Glossary/Fetch_directive). +# +# This is convenient as you do not have to specify all Fetch directives +# that apply to your site, for example: +# `connect-src 'self'; font-src 'self'; script-src 'self'; style-src 'self'`, etc. +# +# This restriction also means that you must explicitly define from which +# site(s) your website is allowed to load resources from. +# +# (2) The `` element is not allowed on the website. This is to prevent +# attackers from changing the locations of resources loaded from relative +# URLs. +# +# If you want to use the `` element, then `base-uri 'self'` can be +# used instead. +# +# (3) Form submissions are only allowed from the current website by setting: +# `form-action 'self'`. +# +# (4) Prevents all websites (including your own) from embedding your webpages +# within e.g. the `