forro

Forro is a end-to-end encrypted contract form based on PGP.
git clone git://git.defalsify.org/forro.git
Log | Files | Refs | LICENSE

commit f3a10f861e23b7f1adfae0df9d60a9de5029d4d2
parent 84579a6b11b637c8f6bf4bacb9c6af46ca68e55c
Author: lash <dev@holbrook.no>
Date:   Mon, 19 Sep 2022 16:06:01 +0000

Add funny default names

Diffstat:
MCHANGELOG | 3+++
Mindex.html | 30++++++++++++++++++++++++------
Mkey.js | 11+++++++++--
Aname.js | 32++++++++++++++++++++++++++++++++
Mpackage.json | 2+-
5 files changed, 69 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,3 +1,6 @@ +- 0.0.3 + * add (optional) userid info for sender + * use funny names for default userid - 0.0.2 * add public key submission - 0.0.1 diff --git a/index.html b/index.html @@ -7,6 +7,8 @@ let g_remote_key = undefined; let g_local_key = undefined; let g_remote_key_id = '(none)'; let g_local_key_id = '(none)'; +let g_remote_key_name = '?'; +let g_local_key_name = '?'; let g_data_endpoint = window.location.href; let g_counter = undefined; </script> @@ -14,6 +16,7 @@ let g_counter = undefined; <script src="node_modules/jssha/dist/sha256.js"></script> <script defer src="node_modules/alpinejs/dist/cdn.min.js"></script> <script src="key.js"></script> + <script src="name.js"></script> <script> // Thanks to: @@ -45,13 +48,26 @@ let g_counter = undefined; stateChange('attempt load local signing key'); k = await getKey('deadbeef'); } catch { - stateChange('generate local signing key'); - k = await generatePGPKey('deadbeef'); + stateChange('generate initial bogus name'); + let name = generateName(); + let uid = { + 'name': name, + 'email': 'test@devnull.holbrook.no', + }; + console.debug('you will initially be called', uid.name); + + stateChange('generate new local signing key'); + k = await generatePGPKey('deadbeef', uid); }; g_local_key = k; g_local_key_id = k.getKeyID().toHex(); + let kl = k.toPacketList(); + let klf = kl.filterByTag(openpgp.enums.packet.userID); + g_local_key_name = klf[klf.length-1].name; + + stateChange('load settings'); let settings = await loadSettings(); if (settings.data_endpoint !== undefined) { @@ -75,8 +91,10 @@ let g_counter = undefined; }); g_remote_key = remote_key; g_remote_key_id = g_remote_key.getKeyID().toHex(); - - stateChange('ready to send'); + g_remote_key.getPrimaryUser().then((v) => { + g_remote_key_name = v.user.userID.name; + stateChange('ready to send'); + }); } async function stateChange(s) { @@ -87,8 +105,8 @@ let g_counter = undefined; detail: { s: s, c: g_counter, - kr: g_remote_key_id, - kl: g_local_key_id, + kr: g_remote_key_id + ' (' + g_remote_key_name + ')', + kl: g_local_key_id + ' (' + g_local_key_name + ')', }, }); window.dispatchEvent(ev); diff --git a/key.js b/key.js @@ -1,10 +1,17 @@ -async function generatePGPKey(pwd) { +async function generatePGPKey(pwd, uid) { + if (uid === undefined) { + uid = { + name: "Ola Nordmann", + email: "ola@nordmann.no", + }; + } + uid.comment = 'Generated by forro v0.0.3, openpgpjs/5.5.0'; return new Promise(async (whohoo, doh) => { let v = await openpgp.generateKey({ //type: 'ecc', //curve: 'secp256k1', type: 'rsa', - userIDs: [{name: "Ola Nordmann", email: "ola@nordmann.no" }], + userIDs: [uid], passphrase: pwd, format: 'armored', //config: { rejectCurves: new Set() }, diff --git a/name.js b/name.js @@ -0,0 +1,32 @@ +// pinched from https://stackoverflow.com/questions/16826200/javascript-silly-name-generator +let name_parts = [ + ["Runny", "Buttercup", "Dinky", "Stinky", "Crusty", + "Greasy","Gidget", "Cheesypoof", "Lumpy", "Wacky", "Tiny", "Flunky", + "Fluffy", "Zippy", "Doofus", "Gobsmacked", "Slimy", "Grimy", "Salamander", + "Oily", "Burrito", "Bumpy", "Loopy", "Snotty", "Irving", "Egbert"], + + ["Waffer", "Lilly","Rugrat","Sand", "Fuzzy","Kitty", + "Puppy", "Snuggles","Rubber", "Stinky", "Lulu", "Lala", "Sparkle", "Glitter", + "Silver", "Golden", "Rainbow", "Cloud", "Rain", "Stormy", "Wink", "Sugar", + "Twinkle", "Star", "Halo", "Angel"], + ["Snicker", "Buffalo", "Gross", "Bubble", "Sheep", + "Corset", "Toilet", "Lizard", "Waffle", "Kumquat", "Burger", "Chimp", "Liver", + "Gorilla", "Rhino", "Emu", "Pizza", "Toad", "Gerbil", "Pickle", "Tofu", + "Chicken", "Potato", "Hamster", "Lemur", "Vermin"], + ["face", "dip", "nose", "brain", "head", "breath", + "pants", "shorts", "lips", "mouth", "muffin", "butt", "bottom", "elbow", + "honker", "toes", "buns", "spew", "kisser", "fanny", "squirt", "chunks", + "brains", "wit", "juice", "shower"], +]; + +function generateName() { + name = ''; + for (let i = 0; i < name_parts.length; i++) { + if (i > 0 && i < 3) { + name += ' '; + } + const ii = Math.random() * name_parts[i].length; + name += name_parts[i][Math.floor(ii)]; + } + return name; +} diff --git a/package.json b/package.json @@ -1,6 +1,6 @@ { "name": "forro", - "version": "0.0.2", + "version": "0.0.3", "license": "GPLv3", "author": "Louis Holbrook <dev@holbrook.no> (https://holbrook.no)", "dependencies": {