Something went wrong. Try again.
a demonstration replicated social networking web app built with anproto wiredove.net
social ed25519 protocols
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394import {h} from 'h'import {apds} from 'apds'
const nameDiv = async () => { const name = await apds.get('name')
const namer = h('input', { placeholder: name || 'Name yourself' })
const namerDiv = h('span', [ namer, h('button', {onclick: async () => { if (namer.value) { namer.placeholder = namer.value await apds.put('name', namer.value) namer.value = '' namerDiv.replaceWith(await genDiv()) } }}, ['Save']) ])
return namerDiv}
const saveButton = async (keypair) => { const button = h('button', { id: 'saveButton', onclick: async () => { await apds.put('keypair', keypair) document.location.reload() } }, ['Save'])
return button}
export const genDiv = async () => { const initial = await apds.generate() const name = await apds.get('name') const pubkey = h('span', {classList: 'pubkey'}) const button = h('button', { onclick: async () => { if (name.length > 1) { const alreadyButton = document.getElementById('saveButton') if (alreadyButton) { alreadyButton.remove() } let done = true const genInterval = setInterval(async _ => { const keypair = await apds.generate() pubkey.textContent = keypair.substring(0, 10) if (keypair.substring(0, 2).toUpperCase() === name.substring(0, 2).toUpperCase()) { clearInterval(genInterval) pubkey.after(await saveButton(keypair)) } }, .000001) } else { await apds.put('keypair', initial) document.location.reload() } } }, ['Generate']) button.click() const div = h('span', [ h('span', [name]), button, ' ', pubkey, ' ', ]) return div}
export const identify = async () => { const span = h('span')
const start = h('button', { onclick: async () => { const div2 = h('span', [ await nameDiv() ])
div1.replaceWith(div2) } }, ['Generate Keypair'])
const div1 = h('span', [start])
if (!await apds.pubkey()) { span.appendChild(div1) } return span}