Ind.ie is now Small Technology Foundation.
Commit e79757cc authored by Aral Balkan's avatar Aral Balkan

Start off where the last spike ended

parent 31e6786f
favicon.ico

14.7 KB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<meta http-equiv='X-UA-Compatible' content='ie=edge'>
<title>Hypha Aspect Setup Spike 1</title>
<link rel='stylesheet' href='style.css'>
<script src='session25519.js'></script>
</head>
<body>
<h1>Hypha Aspect Setup Spike 1</h1>
<form id='passwordForm'>
<fieldset>
<label for='domain'>Domain</label>
<input type='text' id='domain' value='ar.al'>
</fieldset>
<fieldset>
<label>Choose a strong password (min 6 words):</label>
<input type='text' id='password'>
<button id='submit' type='submit'>Submit</button>
</fieldset>
</form>
<form id='outputForm'>
<label for='publicSigningKey'>Public signing key:</label>
<input type='text' id='publicSigningKey'>
<label for='privateSigningKey'>Private signing key:</label>
<textarea id='privateSigningKey'></textarea>
<label for='publicEncryptionKey'>Public encryption key:</label>
<input type='text' id='publicEncryptionKey'>
<label for='privateEncryptionKey'>Private encryption key:</label>
<input type='text' id='privateEncryptionKey'>
</form>
<script>
// From libsodium.
function to_hex(input) {
// Disable input checking for this simple spike.
// input = _any_to_Uint8Array(null, input, "input");
var str = "",
b,
c,
x;
for (var i = 0; i < input.length; i++) {
c = input[i] & 0xf;
b = input[i] >>> 4;
x =
((87 + c + (((c - 10) >> 8) & ~38)) << 8) |
(87 + b + (((b - 10) >> 8) & ~38));
str += String.fromCharCode(x & 0xff) + String.fromCharCode(x >>> 8);
}
return str;
}
// Main
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('password').focus()
document.getElementById('passwordForm').addEventListener('submit', (event) => {
const form = event.target
const password = form.elements.password.value
const domain = form.elements.domain.value
const publicSigningKeyTextField = document.getElementById('publicSigningKey')
const privateSigningKeyTextArea = document.getElementById('privateSigningKey')
const publicEncryptionKeyTextField = document.getElementById('publicEncryptionKey')
const privateEncryptionKeyTextField = document.getElementById('privateEncryptionKey')
session25519(domain, password, (error, keys) => {
if (error) { alert(error); return }
publicSigningKeyTextField.value = to_hex(keys.publicSignKey)
privateSigningKeyTextArea.value = to_hex(keys.secretSignKey)
publicEncryptionKeyTextField.value = to_hex(keys.publicKey)
privateEncryptionKeyTextField.value = to_hex(keys.secretKey)
})
event.preventDefault()
})
})
</script>
</body>
</html>
const fs = require('fs')
const https = require('https')
const { pipeline } = require('stream')
const options = {
key: fs.readFileSync('localhost-key.pem'),
cert: fs.readFileSync('localhost.pem')
}
const routes = {
'/': 'index.html',
'/style.css': 'style.css',
'/session25519.js': 'session25519.js',
'/favicon.ico': 'favicon.ico'
}
https.createServer(options, (request, response) => {
const url = request.url
const fileToServe = routes[url]
if (fileToServe !== undefined) {
response.statusCode = 200
pipeline(fs.createReadStream(fileToServe), response)
} else {
console.log(`Unknown path requested: ${url}`)
response.statusCode = 404
response.end('Not found.')
}
}).listen(443, () => {
console.log('Listening on port 443.')
})
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDdWY5lw7bdd/bI
b8Mm9wNpsVEn6ZlYUOOdcH+Cfbm993oc7yDQsDhr/rIbHT5WgsVOY9JAt647RyAT
8+BNqO8+LNqjBwnhc3vpu/J/JOg/ZTj1TKAyEhNgP/MvJX+0n2AC1ygQISsDaNK/
ML9i2cDwYs/um4V58KS1XUQZCdftVscIBEdnf7hCQnGGkK33IVE0+K6LYCmGfQ+n
LydH/LTtObVc6tqWilbF4x8NOjG5Bx20CzXpNcQOMDnwz7Q/Z8c3Bmiy432H00mI
MfmWJugkadWl0HDZRzZQIeMLM60XgCTGUNZirLhHc4YA/A7gOcJaN06QOhxi+KPa
Ln89dyk1AgMBAAECggEBAIgsVjwo4VDyQnIgv5AzGnhlS6YgQeRhLwZmdStUKXbC
zu8J9cgtASj/MZcYsIcMQFHveyOxXJC/Ou7Lc8yTB0va0E7HP77hCvRKWe76R57o
qNfP4iWrlRv7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WgWVYWZZDpMgZSnpue2/q2LE5VB/xLovGsaB4Ci/8mNMl
3hbZgy/9iyryWDbsDduE97SGWix9wPoDudBnUVjaN59cdAUGS1QKVQtD9UuvU0nh
ZTm5eysomJjm5WiWCBardhsnEOI/tlJe21uwRcsJjb2fPetmNJnktH57BYzutAzJ
mzKnk7AXETCZuLHXu2MUnJjbgW/1JWAC8XzITTua+2mC3n+KZtZkv+0TAwe/BDaC
OFtJ3fnCuktbXBImR641VTWDQMEGBawYkDYGZbRZ3kz+pM4KyS57nodMQA7nHW3L
8b5VJEg4iNeDR0awUcQvs+pPhrkyq6gc7DejmuSpgvL8IUXNjD+V9tReb2Piw3D8
vAQcotgSgWyJtKpPnOODtKlXJE3yOLNjhfxpgWWtLJjQnsC30VVKOBeEKpvZKzXV
t2GHOw==
-----END CERTIFICATE-----
{
"name": "aspect-setup-1",
"version": "1.0.0",
"description": "Aspect setup spike",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@source.ind.ie:hypha/spikes/aspect-setup-1.git"
},
"keywords": [
"hypha",
"aspect",
"setup"
],
"author": "Aral Balkan",
"license": "AGPL-3.0-or-later"
}
This source diff could not be displayed because it is too large. You can view the blob instead.
* {
box-sizing: border-box;
}
html {
font-family: sans-serif;
}
form {
width: 100%;
padding: 2em;
}
fieldset {
display: grid;
grid-template-columns: 200px 1fr 100px;
border: 0;
padding: 0;
margin: 0;
}
input, textarea {
font-size: 1em;
border: 1px solid black;
padding: 0.5em;
}
#outputForm {
overflow: auto;
}
#outputForm label {
display: block;
}
#outputForm input, textarea {
width: 100%;
margin-bottom: 1em;
}
#outputForm textArea {
height: 4em;
background-color: white;
color: black;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment