<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>cryptex in the browser</title>
<link rel="icon" href="data:," />
<style>
:root {
color-scheme: light dark;
font-family: system-ui, sans-serif;
}
body {
margin: 0 auto;
max-width: 42rem;
padding: 2rem 1rem;
line-height: 1.5;
}
h1 {
font-size: 1.4rem;
}
fieldset {
border: 1px solid currentColor;
border-radius: 0.5rem;
margin-bottom: 1rem;
padding: 0.75rem 1rem;
}
label {
display: block;
margin: 0.5rem 0 0.25rem;
}
input,
select,
button {
font: inherit;
padding: 0.35rem 0.5rem;
}
input {
width: 100%;
box-sizing: border-box;
}
button {
margin: 0.5rem 0.25rem 0 0;
cursor: pointer;
}
#status {
white-space: pre-wrap;
font-family: ui-monospace, monospace;
font-size: 0.9rem;
border-left: 3px solid currentColor;
padding-left: 0.75rem;
min-height: 1.5em;
}
.hint {
font-size: 0.85rem;
opacity: 0.75;
}
.list {
list-style: none;
margin: 0;
padding: 0;
font-family: ui-monospace, monospace;
font-size: 0.9rem;
}
.list li {
padding: 0.15rem 0;
}
.list .open {
opacity: 0.75;
}
button.link {
background: none;
border: none;
margin: 0;
padding: 0;
font: inherit;
color: inherit;
text-decoration: underline;
cursor: pointer;
}
button.link:disabled {
text-decoration: none;
cursor: default;
opacity: 0.75;
}
.list .store {
display: inline-block;
min-width: 6.5rem;
font-size: 0.75rem;
opacity: 0.6;
}
</style>
</head>
<body>
<h1>cryptex in the browser</h1>
<p class="hint">
A keyring is a Turso database, either kept in IndexedDB (one image per
keyring) or in localStorage. Everything you store is encrypted with a key
derived from the password; any script on this origin can read the
ciphertext, so pick a password you would not reuse carelessly.
</p>
<fieldset>
<legend>Keyring</legend>
<label for="password">Password</label>
<input id="password" type="password" value="correct-horse-battery-staple" autocomplete="off" />
<label for="name">Name</label>
<input id="name" type="text" value="example" autocomplete="off" />
<label for="store">Store</label>
<select id="store">
<option value="indexeddb" selected>IndexedDB</option>
<option value="localstorage">localStorage</option>
</select>
<button id="open">Open</button>
<button id="persist">Ask for persistent storage</button>
</fieldset>
<fieldset>
<legend>Secret</legend>
<label for="id">Name</label>
<input id="id" type="text" value="api-token" autocomplete="off" />
<label for="value">Value</label>
<input id="value" type="text" value="s3cret" autocomplete="off" />
<button id="set">Store</button>
<button id="get">Read</button>
<button id="delete">Delete</button>
<button id="export">Copy image</button>
</fieldset>
<fieldset>
<legend>Keyrings in this browser</legend>
<ul id="keyrings" class="list">
<li class="hint">Loading…</li>
</ul>
</fieldset>
<fieldset>
<legend>Keys in the open keyring</legend>
<ul id="keys" class="list">
<li class="hint">Open a keyring to see its keys.</li>
</ul>
</fieldset>
<p id="status">Not opened.</p>
<script type="module" src="./main.js"></script>
</body>
</html>