Skip to content

Commit

Permalink
#6: Registration webpage
Browse files Browse the repository at this point in the history
  • Loading branch information
gsvarovsky committed Jul 27, 2023
1 parent b4fa4ce commit 857c270
Show file tree
Hide file tree
Showing 29 changed files with 344 additions and 138 deletions.
14 changes: 9 additions & 5 deletions architecture/gateway design.mm
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
</node>
<node TEXT="gateway domain integrity" ID="ID_45707719" CREATED="1669712202161" MODIFIED="1669712245290" LINK="https://github.com/m-ld/timeld/tree/main/architecture/use-case"/>
</node>
<node TEXT="app API" ID="ID_711185593" CREATED="1669710794892" MODIFIED="1670153502401">
<node TEXT="clone API" ID="ID_711185593" CREATED="1669710794892" MODIFIED="1690270788680">
<icon BUILTIN="bookmark"/>
<arrowlink SHAPE="CUBIC_CURVE" COLOR="#000000" WIDTH="1" TRANSPARENCY="200" FONT_SIZE="9" FONT_FAMILY="SansSerif" DESTINATION="ID_452328659" STARTINCLINATION="474;0;" ENDINCLINATION="474;0;" STARTARROW="NONE" ENDARROW="NONE"/>
<node TEXT="state locking" ID="ID_823798417" CREATED="1669710817156" MODIFIED="1669917187426">
Expand Down Expand Up @@ -287,11 +287,15 @@
</node>
<node TEXT="authorisation" ID="ID_1380782440" CREATED="1669709255654" MODIFIED="1669709258287">
<node TEXT="issues" ID="ID_146791554" CREATED="1669709258814" MODIFIED="1669709599496">
<node TEXT="#97 client security clauses" ID="ID_1391926953" CREATED="1669712573659" MODIFIED="1669712580035"/>
<node TEXT="#95 socket.io offline" ID="ID_285509041" CREATED="1669709308838" MODIFIED="1669714755514">
<icon BUILTIN="bookmark"/>
<node TEXT="#97 client security clauses" ID="ID_1391926953" CREATED="1669712573659" MODIFIED="1690270687668">
<icon BUILTIN="checked"/>
</node>
<node TEXT="#95 socket.io offline" ID="ID_285509041" CREATED="1669709308838" MODIFIED="1690270706693">
<icon BUILTIN="checked"/>
</node>
<node TEXT="#36 remove dep on Node 16" ID="ID_787835182" CREATED="1669709961849" MODIFIED="1690270710092">
<icon BUILTIN="checked"/>
</node>
<node TEXT="#36 remove dep on Node 16" ID="ID_787835182" CREATED="1669709961849" MODIFIED="1669709973626"/>
</node>
<node TEXT="asymmetric crypto" ID="ID_41229526" CREATED="1669709511775" MODIFIED="1669710103466">
<node TEXT="optional" ID="ID_1904946102" CREATED="1669710036625" MODIFIED="1669714768102">
Expand Down
15 changes: 15 additions & 0 deletions doc/_includes/doc.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
layout: page.liquid
---
<section class="container is-fluid">
<div class="content columns">
<div class="column is-3 has-background-light">
{% include 'sidebar' %}
</div>
<div class="column is-9">
<div class="container is-fluid">
<div class="content">{{ content }}</div>
</div>
</div>
</div>
</section>
3 changes: 2 additions & 1 deletion doc/_includes/navbar.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
<div class="navbar-end">
<div class="navbar-item">
<div class="buttons">
<a href="register" class="button is-primary">register</a>
{% include 'example-project-button.html' %}
<a href="https://m-ld.org/hello/" class="button is-primary">feedback</a>
<a href="https://m-ld.org/hello/" class="button is-info">feedback</a>
</div>
</div>
</div>
Expand Down
26 changes: 14 additions & 12 deletions doc/_includes/page.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ permalink: "{{ page.filePathStem }}"
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>m-ld | {{ doc.title | default: title }}</title>
<link rel="stylesheet" href="/main.css">
<link href="prism.css" rel="stylesheet" />
<link href="prism.css" rel="stylesheet"/>
<style media="screen">
body {
display: flex;
min-height: 100vh;
flex-direction: column;
}
#wrapper {
flex: 1;
}
</style>
</head>

<body id="{{ doc.id | default: page.fileSlug }}" class="{{ doc.class }}">
{% include 'navbar' %}
<div class="container is-fluid">
<div class="content columns">
<div class="column is-3 has-background-light">
{% include 'sidebar' %}
</div>
<div class="column is-9">
<div class="container is-fluid">
<div class="content">{{ content }}</div>
</div>
</div>
</div>
<div id="wrapper">
{{ content }}
</div>
{% include 'footer' %}
<script src="prism.js"></script>
Expand Down
10 changes: 5 additions & 5 deletions doc/accounts.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: page.liquid
layout: doc.liquid
title: accounts
---
[//]: # (cURLs in this file are generated from the .http file using http-client.env.json)
Expand All @@ -18,7 +18,7 @@ Account names (`≪account≫` in the below) must be composed only of **lowercas

First, request an activation code with an email address.

```curl
```bash
curl -X POST --location "https://≪gateway≫/api/v1/user/≪account≫/activation" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
Expand All @@ -31,7 +31,7 @@ An email will be sent to the given address, containing a six-digit activation co

The account can then be created with another HTTP request:

```curl
```bash
curl -X POST --location "https://≪gateway≫/api/v1/user/≪account≫/key" \
-H "Authorization: Bearer ≪jwe≫" \
-H "X-Activation-Code: ≪emailed activation code≫" \
Expand All @@ -44,7 +44,7 @@ The body of the response will be of the form `{ "auth": { "key": "≪my-key≫"

The Gateway root account can be used to create any user account directly.

```curl
```bash
curl -X POST --location "https://≪gateway≫/api/v1/user/≪account name≫/key" \
-H "Accept: application/json" \
--basic --user ≪root≫:≪root key≫
Expand All @@ -61,7 +61,7 @@ When [connecting to subdomains](clone-subdomain), clients may need to provide au

The required option can be set as follows.

```curl
```bash
curl -X PATCH --location "https://≪gateway≫/api/v1/user/≪account name≫" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
Expand Down
84 changes: 84 additions & 0 deletions doc/activate.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
layout: page.liquid
---
<section class="columns is-mobile">
<div class="column"></div>
<article class="column box is-narrow">
<form action="/activate" method="post">
<div class="field">
<label class="label" for="codeInput">Activation Code</label>
<div class="control">
<input id="codeInput"
name="code"
class="input"
type="text"
placeholder="activation code"
pattern="[0-9]{6}"
title="six digits"
autofocus
required>
</div>
<p class="help">Enter the activation code we sent to {{ '{{ email }}' }}.</p>
</div>
{% comment %}
Server-provided value for loopback (see form action)
{% endcomment %}
<input name="jwe" type="hidden" value="{{ '{{ jwe }}' }}">
<div class="control">
<button class="button is-primary">Submit</button>
</div>
</form>
</article>
<div class="column"></div>
</section>
{{ '{% if key %}' }}
<div id="result" class="modal is-active">
<div class="modal-background"></div>
<div class="modal-content">
<article class="message is-success">
<div class="message-header">
<p>Account {{ '{{ account }}' }} was created!</p>
</div>
<div class="message-body field">
<label class="label" for="keyText">
Your new account key
</label>
<div class="control">
<textarea id="keyText"
class="textarea is-family-monospace"
onfocus="this.select()"
readonly>{{ '{{ key }}' }}</textarea>
</div>
<p class="help">We don't keep your key, so copy it to somewhere safe.</p>
</div>
</article>
</div>
<a class="modal-close is-large"
aria-label="close"
href="named-subdomains"></a>
</div>
{{ '{% elsif error %}' }}
<div id="result" class="modal is-active">
<div class="modal-background"></div>
<div class="modal-content">
<article class="message is-danger">
<div class="message-header">
<p>{{ '{{ error.code }}' }}</p>
</div>
<div class="message-body">
<p>{{ '{{ error.message }}' }}</p>
<p class="help">Sorry. Let's <a href="register">try that again</a>.</p>
</div>
</article>
</div>
<a class="modal-close is-large"
aria-label="close"
href="register"></a>
</div>
{{ '{% endif %}' }}
<script>
document.addEventListener('keydown', e => {
if (e.key === 'Escape')
document.querySelector('#result .modal-close').click();
});
</script>
6 changes: 3 additions & 3 deletions doc/clone-api.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: page.liquid
layout: doc.liquid
title: clone API
---
[//]: # (cURLs in this file are generated from the .http file using http-client.env.json)
Expand All @@ -17,7 +17,7 @@ The 'clone' (noun, not verb) API is provided for such a client to access the dat

Some data can be added to the domain with:

```curl
```bash
curl -X POST --location "https://≪gateway≫/api/v1/domain/≪account name≫/≪subdomain≫/state" \
-H "Content-Type: application/json" \
-d "{
Expand All @@ -29,7 +29,7 @@ curl -X POST --location "https://≪gateway≫/api/v1/domain/≪account name≫/

Data in the domain can be queried with:

```curl
```bash
curl -X GET --location "https://≪gateway≫/api/v1/domain/≪account name≫/≪subdomain≫/state?q=%7B%22%40describe%22%3A%22%3Fid%22%2C%22%40where%22%3A%7B%22%40id%22%3A%22%3Fid%22%7D%7D" \
-H "Accept: application/json" \
--basic --user ≪account name≫:≪account key≫
Expand Down
2 changes: 1 addition & 1 deletion doc/clone-subdomain.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: page.liquid
layout: doc.liquid
title: getting started
---
# Cloning a Subdomain
Expand Down
2 changes: 1 addition & 1 deletion doc/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: page.liquid
layout: doc.liquid
title: getting started
---
# Getting Started
Expand Down
2 changes: 1 addition & 1 deletion doc/http-client.env.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"local": {
"gateway": "http://localhost:62774",
"gateway": "http://localhost:3000",
"account": "my-account",
"remotesAuth": "anon",
"subdomain": "my-subdomain"
Expand Down
1 change: 1 addition & 0 deletions doc/index.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ permalink: "index"
<div class="buttons level-item">
{% comment %}<a class="button is-primary">register</a>{% endcomment %}
<a class="button is-link" href="getting-started">docs</a>
<a class="button is-primary" href="register">register</a>
{% include 'example-project-button.html' %}
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions doc/named-subdomains.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: page.liquid
layout: doc.liquid
title: named subdomains
---
[//]: # (cURLs in this file are generated from the .http file using http-client.env.json)
Expand All @@ -14,7 +14,7 @@ To use named subdomains, you first need [an account](accounts). (If your Gateway

A new domain can be created with:

```curl
```bash
curl -X PUT --location "https://≪gateway≫/api/v1/domain/≪account name≫/≪subdomain≫" \
-H "Accept: application/json" \
--basic --user ≪account name≫:≪account key≫
Expand Down
45 changes: 45 additions & 0 deletions doc/register.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
layout: page.liquid
---
<section class="columns is-mobile">
<div class="column"></div>
<div class="column box is-narrow">
<h1 class="title">Register an Account</h1>
<p class="help">Enter the details below to register a new account.</p>
<p class="help">You can also use this form to get a new key for an existing account.</p>
<hr/>
<form action="/activate" method="post">
<div class="field">
<label class="label" for="accInput">Account Name</label>
<div class="control">
<input id="accInput"
name="account"
class="input"
type="text"
placeholder="new account name"
pattern="[a-z0-9\-_]+"
title="lowercase letters, digits and dashes"
autofocus
required>
</div>
<p class="help">May only contain lowercase letters, digits and dashes.</p>
</div>
<div class="field">
<label class="label" for="emailInput">Email</label>
<div class="control">
<input id="emailInput"
name="email"
class="input"
type="email"
placeholder="your email"
required>
</div>
<p class="help">We'll send an activation code to this address.</p>
</div>
<div class="control">
<button class="button is-primary">Submit</button>
</div>
</form>
</div>
<div class="column"></div>
</section>
6 changes: 3 additions & 3 deletions doc/self-host.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
layout: page.liquid
layout: doc.liquid
title: self-hosting setup
---
# Hosting a Gateway

## build
```shell
```bash
npm run build
```

Expand All @@ -32,7 +32,7 @@ The data path can be omitted, in which case a local path will be used in an OS-s

For convenience these variables can be specified in a `.env` file in the working directory.

```shell
```bash
npm run start -- --genesis true
```

Expand Down
6 changes: 3 additions & 3 deletions doc/uuid-subdomains.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
layout: page.liquid
layout: doc.liquid
title: uuid subdomains
---

Expand All @@ -18,7 +18,7 @@ To use UUID subdomains, you first need [an account](accounts).

By default, a Gateway account only allows [named subdomains](named-subdomains). To enable UUID subdomains for an account:

```curl
```bash
curl -X PATCH --location "https://≪gateway≫/api/v1/user/≪account name≫" \
-H "Content-Type: application/json" \
-d "{ \"@insert\": { \"naming\": \"uuid\" } }" \
Expand All @@ -33,7 +33,7 @@ The domain name must take the form `≪uuid≫.my-account.my-gateway`, where `

For convenience, you can request suitable configuration for a new UUID subdomain from the Gateway, as follows. Note that this does not create anything new on the Gateway, but it will generate a compliant UUID for the domain name.

```curl
```bash
curl -X POST --location "https://≪gateway≫/api/v1/domain/≪account name≫" \
-H "Accept: application/json"
```
Expand Down
Loading

0 comments on commit 857c270

Please sign in to comment.