diff --git a/app/.well-known/assetlinks.json b/app/.well-known/assetlinks.json new file mode 100644 index 000000000..dac319e74 --- /dev/null +++ b/app/.well-known/assetlinks.json @@ -0,0 +1,10 @@ +[{ + "relation": ["delegate_permission/common.handle_all_urls"], + "target": { + "namespace": "android_app", + "package_name": "org.mapcomplete", + "sha256_cert_fingerprints": + ["16:76:16:29:FE:F7:61:C1:E8:52:2E:63:89:E9:A2:B2:76:87:16:79:E4:D4:92:17:35:B6:3A:17:90:6D:35:6C"] + } +}] + diff --git a/app/README.md b/app/README.md new file mode 100644 index 000000000..1bac4c74e --- /dev/null +++ b/app/README.md @@ -0,0 +1,28 @@ +# app-directory + +This directory contains the files for "https://app.mapcomplete.org". This does _not_ contain the Android files, but it contains some helper HTML. + +The main function is to help authentication. + +The authentication flow in a nutshell: + +1. The user want to authenticate +2. The app opens a browser window, showing the OSM.org login page +3. The browser redirects to "app.mapcomplete.org/land.html"; which obtains an authentication token +4. Once the token is obtained, the browser redirects to "app.mapcomplete.org/passthrough.html?auth_token=<...>". +5. This URL is an "authenticated URL" and will thus be opened in the app, where +6. The native shell receives the intent with the authentication token +7. The native shell passes this to the web context +8. The webcontext passes the token to the OSM-connection +9. ??? +10. Profit! + +## The 'assetlinks-file' + +The hidden folder ".well-known" should be put on the website as well; `https://app.mapcomplete.org/.well-known/assetlinks.json` must return the relevant JSON + +## A note about building and deploying + +These files should be relatively static and not change a lot. The deploy script is included in this directory (but not in CI) + +These are deployed in the hetzner server in the `/root/app/*`-directory; see [the hetzner caddyfile](../Docs/ServerConfig/hetzner/Caddyfile) for more info diff --git a/app/app.vite.config.js b/app/app.vite.config.js new file mode 100644 index 000000000..2231f8eea --- /dev/null +++ b/app/app.vite.config.js @@ -0,0 +1,28 @@ +import { defineConfig } from "vite" +import { svelte } from "@sveltejs/vite-plugin-svelte" +import fs from "fs" +import basicSsl from "@vitejs/plugin-basic-ssl" + +const input = { "land": "./app/land.html", passthrough: "./app/passthrough.html" } + + +console.log("Args:", process.argv) +const plugins = [svelte()] +if (process.argv.indexOf("--https") >= 0) { + console.log("Adding basicSSL") + plugins.push(basicSsl()) +} +const ASSET_URL = process.env.ASSET_URL || "" +export default defineConfig({ + build: { + rollupOptions: { + input, + }, + outDir: "./app/dist/", + }, + base: `./app/`, + plugins, + server: { + port: 1234, + }, +}) diff --git a/app/build_and_deploy.sh b/app/build_and_deploy.sh new file mode 100755 index 000000000..edc551150 --- /dev/null +++ b/app/build_and_deploy.sh @@ -0,0 +1,19 @@ +#! /bin/bash + +nvm use +export NODE_OPTIONS="--max-old-space-size=8192" + +npm run build:vite:app-landing + +mkdir to_upload +mv dist/app/* to_upload/ +cp -r .well-known/ to_upload/ +mkdir -p to_upload/assets +cp dist/assets/*.js to_upload/assets/ +rm -rf dist + +ssh hetzner "rm -rf /root/app/" +scp -rp to_upload/ hetzner:/root/app/ +scp -rp to_upload/.well-known/ hetzner:/root/app/ + +rm -rf to_upload diff --git a/app/land.html b/app/land.html new file mode 100644 index 000000000..1db658018 --- /dev/null +++ b/app/land.html @@ -0,0 +1,8 @@ + + +