Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

4.8 KB
Raw Blame
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--ID_DELETE_CSP-->
<title>Delete your bento/id — bento.page</title>
<meta name="description" content="Remove your email address and keys from the bento/id directory.">
<meta name="robots" content="noindex">
<link rel="canonical" href="https://bento.page/id/delete">
<style>
:root{--ink:#0D1B2E;--panel:#16273E;--text:rgba(196,206,221,.92);--dim:rgba(182,193,210,.62);--white:#F4F6F9;--peach:#FF9E8A;--line:rgba(182,193,210,.24)}
*{margin:0;padding:0;box-sizing:border-box}
body{background:var(--ink);color:var(--text);font-family:'Instrument Sans',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;line-height:1.6}
a{color:var(--peach)}
main{max-width:560px;margin:0 auto;padding:48px 16px 80px}
h1{color:var(--white);font-family:Fraunces,Georgia,serif;font-size:clamp(28px,5vw,38px);line-height:1.1;margin-bottom:12px}
p{margin:0 0 12px}
label{display:block;color:var(--white);font-weight:600;margin:16px 0 6px}
input{width:100%;font:inherit;padding:10px 12px;border-radius:10px;border:1px solid var(--line);background:var(--panel);color:var(--white)}
input:focus{outline:2px solid var(--peach);outline-offset:1px}
button{margin-top:14px;font:inherit;font-weight:700;padding:10px 22px;border-radius:999px;border:0;background:var(--peach);color:var(--ink);cursor:pointer}
button[disabled]{opacity:.5;cursor:default}
#status{margin-top:16px;min-height:1.6em}
#status[data-kind="error"]{color:#ffb4a6}
[hidden]{display:none!important}
.small{color:var(--dim);font-size:14px;margin-top:24px}
</style>
</head>
<body>
<main>
<h1>Delete your bento/id</h1>
<p>This removes your email address, keys and any recovery data from the
bento/id directory. People who look up your address will see that it was
withdrawn. Files you have on your devices, and copies other people already
have, are not affected.</p>
<p>If you still have bento/home, you can also do this there.</p>

<form id="step-email" novalidate>
  <label for="email">Email address</label>
  <input id="email" type="email" autocomplete="email" required>
  <button id="send" type="submit">Send a code</button>
</form>

<form id="step-code" novalidate hidden>
  <p id="sent"></p>
  <label for="code">Code</label>
  <input id="code" inputmode="text" autocomplete="one-time-code" autocapitalize="characters" spellcheck="false" maxlength="8" required>
  <button id="confirm" type="submit">Delete my bento/id</button>
</form>

<p id="status" role="status" aria-live="polite"></p>
<p class="small">What we store and why: <a href="/id/privacy">bento/id privacy notice</a>.</p>
</main>
<script>
(() => {
  'use strict'
  const API = '__ID_API__'
  const $ = (id) => document.getElementById(id)
  const say = (text, kind) => { const s = $('status'); s.textContent = text; s.dataset.kind = kind || '' }
  let email = ''

  const post = async (path, body) => {
    try {
      return await fetch(API + path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) })
    } catch {
      return null
    }
  }

  $('step-email').addEventListener('submit', async (e) => {
    e.preventDefault()
    email = $('email').value.trim()
    if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) return say('Enter the email address your bento/id uses.', 'error')
    $('send').disabled = true
    say('Sending…')
    const r = await post('/v1/delete/start', { email })
    $('send').disabled = false
    if (!r) return say('Could not reach the directory. Check your connection and try again.', 'error')
    if (r.status === 400) return say('That doesn’t look like an email address the directory accepts.', 'error')
    // 202 whatever the directory holds: the page never says whether an address exists
    $('step-email').hidden = true
    $('step-code').hidden = false
    $('sent').textContent = 'If ' + email + ' has a bento/id, we’ve sent it a code. It expires in 20 minutes.'
    say('')
    $('code').focus()
  })

  $('step-code').addEventListener('submit', async (e) => {
    e.preventDefault()
    const code = $('code').value.trim().toUpperCase()
    if (!/^[23456789ABCDEFGHJKMNPQRSTUVWXYZ]{8}$/.test(code)) return say('The code is 8 letters and numbers, as in the email.', 'error')
    $('confirm').disabled = true
    say('Deleting…')
    const r = await post('/v1/delete/complete', { email, code })
    $('confirm').disabled = false
    if (!r) return say('Could not reach the directory. Check your connection and try again.', 'error')
    if (r.status === 204) {
      $('step-code').hidden = true
      return say('Done. Your bento/id has been removed from the directory.')
    }
    if (r.status === 429) return say('Too many attempts from this network. Try again in an hour.', 'error')
    say('That code didn’t work. Check it, or start again for a new one.', 'error')
  })
})()
</script>
</body>
</html>