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

Organise repository to split client/server code; now works with budo

parent c601f6f1
const session25519 = require('session25519')
const diceware = require('eff-diceware-passphrase')
// 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()
})
})
......@@ -6,7 +6,6 @@
<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>
......@@ -37,53 +36,6 @@
<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>
<script src='bundle.js'></script>
</body>
</html>
......@@ -419,6 +419,28 @@
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.12.0.tgz",
"integrity": "sha512-DYWGk01lDcxeS/K9IHPGWfT8PsJmbXRtRd2Sx72Tnb8pcYZQFF1oSDb8hJtS1vhp212q1Rzi5dUf9+nq0o9UIg=="
},
"blake2b": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/blake2b/-/blake2b-2.1.3.tgz",
"integrity": "sha512-pkDss4xFVbMb4270aCyGD3qLv92314Et+FsKzilCLxDz5DuZ2/1g3w4nmBbu6nKApPspnjG7JcwTjGZnduB1yg==",
"requires": {
"blake2b-wasm": "^1.1.0",
"nanoassert": "^1.0.0"
}
},
"blake2b-wasm": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/blake2b-wasm/-/blake2b-wasm-1.1.7.tgz",
"integrity": "sha512-oFIHvXhlz/DUgF0kq5B1CqxIDjIJwh9iDeUUGQUcvgiGz7Wdw03McEO7CfLBy7QKGdsydcMCgO9jFNBAFCtFcA==",
"requires": {
"nanoassert": "^1.0.0"
}
},
"blake2s-js": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/blake2s-js/-/blake2s-js-1.3.0.tgz",
"integrity": "sha512-+H4oLkODOSeDfDD11PxaZ3Gqi9mtr0QribQRPkQ+v29ZQ689mK/rk5hUVtEjgh3Vq8c4uHPALV0rWjfC6ygrug=="
},
"bn.js": {
"version": "4.11.8",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz",
......@@ -1086,6 +1108,15 @@
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"eff-diceware-passphrase": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/eff-diceware-passphrase/-/eff-diceware-passphrase-1.0.0.tgz",
"integrity": "sha1-c+usW1W01qh0HfEdTQCLCX+jj7s=",
"requires": {
"secure-sample": "^1.0.2",
"secure-shuffle": "^1.1.0"
}
},
"elliptic": {
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz",
......@@ -2092,6 +2123,12 @@
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"ini": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
"optional": true
},
"inject-lr-script": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/inject-lr-script/-/inject-lr-script-2.1.0.tgz",
......@@ -2630,6 +2667,11 @@
"integrity": "sha512-JY7V6lRkStKcKTvHO5NVSQRv+RV+FIL5pvDoLiAtSL9pKlC5x9PKQcZDsq7m4FO4d57mkhC6Z+QhAh3Jdk5JFw==",
"optional": true
},
"nanoassert": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/nanoassert/-/nanoassert-1.1.0.tgz",
"integrity": "sha1-TzFS4JVA/eKMdvRLGbvNHVpCR40="
},
"nanomatch": {
"version": "1.2.13",
"resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz",
......@@ -2653,6 +2695,12 @@
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ=="
},
"node-gyp-build": {
"version": "3.7.0",
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-3.7.0.tgz",
"integrity": "sha512-L/Eg02Epx6Si2NXmedx+Okg+4UHqmaf3TNcxd50SF9NQGcJaON3AtU++kax69XV7YWz4tUspqZSAsVofhFKG2w==",
"optional": true
},
"normalize-path": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
......@@ -3198,6 +3246,38 @@
"ret": "~0.1.10"
}
},
"scrypt-async": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/scrypt-async/-/scrypt-async-1.3.1.tgz",
"integrity": "sha1-oR/W+smBtLgj7gHe4CIRaVAN2uk="
},
"secure-random-uniform": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/secure-random-uniform/-/secure-random-uniform-3.1.0.tgz",
"integrity": "sha512-uRsCi2xIEhGx73ZW3k4OCIdEvN/N+Xk8GFPaFoYpguHoc2Qx1IZZGLmwM2eSmLShutyD9ve/lF0nx5MjGXbhmg==",
"requires": {
"nanoassert": "^1.1.0",
"randombytes": "^2.0.3",
"sodium-universal": "^2.0.0"
}
},
"secure-sample": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/secure-sample/-/secure-sample-1.0.3.tgz",
"integrity": "sha512-ps5Vij3/L8Pvak1sIYVyAWUIjcNCl3iLncOZB4KvtIzmVcsa+YK8lkHeABcf2+jDaZwvCqd9b7dUZR5xgLxF/w==",
"requires": {
"nanoassert": "^1.1.0",
"secure-random-uniform": "^3.0.1"
}
},
"secure-shuffle": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/secure-shuffle/-/secure-shuffle-1.2.0.tgz",
"integrity": "sha512-qQOYsWraLtuXecL8BzUFp9tWM6rF0+9rgsvFKsj4LF4yoBmQs7FSLGVlNfnBAZ7PPsQDB22X6oE6a6Sa7EEqgw==",
"requires": {
"secure-random-uniform": "^3.0.1"
}
},
"semver": {
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
......@@ -3234,6 +3314,16 @@
"send": "0.16.2"
}
},
"session25519": {
"version": "github:aral/session25519#abbbd8f85894dd584c6b87dfa979c82dd2d3daef",
"from": "github:aral/session25519",
"requires": {
"base64-js": "^1.1.1",
"blake2s-js": "^1.0.3",
"scrypt-async": "^1.2.0",
"tweetnacl": "^0.14.0"
}
},
"set-value": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz",
......@@ -3320,6 +3410,14 @@
"from2-string": "^1.1.0"
}
},
"siphash24": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/siphash24/-/siphash24-1.1.1.tgz",
"integrity": "sha512-dKKwjIoTOa587TARYLlBRXq2lkbu5Iz35XrEVWpelhBP1m8r2BGOy1QlaZe84GTFHG/BTucEUd2btnNc8QzIVA==",
"requires": {
"nanoassert": "^1.0.0"
}
},
"snapdragon": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",
......@@ -3417,6 +3515,37 @@
}
}
},
"sodium-javascript": {
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/sodium-javascript/-/sodium-javascript-0.5.5.tgz",
"integrity": "sha512-UMmCHovws/sxIBZsIRhIl8uRPou/RFDD0vVop81T1hG106NLLgqajKKuHAOtAP6hflnZ0UrVA2VFwddTd/NQyA==",
"requires": {
"blake2b": "^2.1.1",
"nanoassert": "^1.0.0",
"siphash24": "^1.0.1",
"xsalsa20": "^1.0.0"
}
},
"sodium-native": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-2.2.4.tgz",
"integrity": "sha512-zE3lJAEN9R/XzJmNUqfyqL3vAnES9rFuyeq5ouHmCOdkVcY5UKbCcl7eUyZ+LG4RcqVfx8CAcgwv9HRpgoNrlg==",
"optional": true,
"requires": {
"ini": "^1.3.5",
"nan": "^2.4.0",
"node-gyp-build": "^3.0.0"
}
},
"sodium-universal": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/sodium-universal/-/sodium-universal-2.0.0.tgz",
"integrity": "sha512-csdVyakzHJRyCevY4aZC2Eacda8paf+4nmRGF2N7KxCLKY2Ajn72JsExaQlJQ2BiXJncp44p3T+b80cU+2TTsg==",
"requires": {
"sodium-javascript": "~0.5.0",
"sodium-native": "^2.0.0"
}
},
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
......@@ -3718,6 +3847,11 @@
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz",
"integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw=="
},
"tweetnacl": {
"version": "0.14.5",
"resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
"integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q="
},
"typedarray": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
......@@ -3963,6 +4097,11 @@
"ultron": "1.0.x"
}
},
"xsalsa20": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/xsalsa20/-/xsalsa20-1.0.2.tgz",
"integrity": "sha512-g1DFmZ5JJ9Qzvt4dMw6m9IydqoCSP381ucU5zm46Owbk3bwmqAr8eEJirOPc7PrXRn45drzOpAyDp8jsnoyXyw=="
},
"xtend": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
......
......@@ -2,7 +2,7 @@
"name": "dat-1",
"version": "1.0.0",
"description": "Hypha Spike: DAT 1",
"main": "index.js",
"main": "server/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
......@@ -20,6 +20,8 @@
"dependencies": {
"@babel/core": "^7.2.2",
"babelify": "^10.0.0",
"budo": "github:aral/budo"
"budo": "github:aral/budo",
"eff-diceware-passphrase": "^1.0.0",
"session25519": "github:aral/session25519"
}
}
......@@ -5,12 +5,15 @@ const { pipeline } = require('stream')
const budo = require('budo')
const babelify = require('babelify')
const server = budo('index.js', {
const server = budo('client/index.js', {
live: true,
port: 443,
ssl: true,
key: 'localhost-key.pem',
cert: 'localhost.pem',
dir: 'client/static/', // Static content directory
key: 'server/localhost-key.pem',
cert: 'server/localhost.pem',
serve: 'bundle.js',
stream: process.stdout, // Log to console
browserify: {
transform: babelify
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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