diff --git a/example/index.ts b/example/index.ts index fc7c8cd..f6dc3f0 100644 --- a/example/index.ts +++ b/example/index.ts @@ -178,14 +178,19 @@ function CodeForm ({ onSubmit }) { async function handleSubmit (ev:SubmitEvent) { ev.preventDefault() - const pin = (ev.target as HTMLFormElement).elements['pin'].value + const pin = (ev.target as HTMLFormElement).elements['pin'] const nameEl = (ev.target as HTMLFormElement).elements['device-name'] const humanReadableDeviceName = nameEl.value - onSubmit({ - code: pin, + debug('got submit event', humanReadableDeviceName) + + await onSubmit({ + code: pin.value, humanReadableDeviceName }) + + pin.value = '' + nameEl.value = '' } function pinInput (ev:InputEvent) { diff --git a/src/index.ts b/src/index.ts index 50978a7..55f3454 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,9 @@ import { PartySocket } from 'partysocket' -import { toString } from 'uint8arrays' +// import { toString } from '@bicycle-codes/identity' import { create as createMessage } from '@bicycle-codes/message' import Debug from '@nichoth/debug' import { + toString, writeKeyToDid, addDevice, createDeviceName @@ -85,6 +86,8 @@ export async function Parent (identity:Identity, oddCrypto:Crypto, { return reject(err) } + debug('parent got a message', msg) + const newIdentity = await addDevice( identity, oddCrypto, @@ -149,6 +152,7 @@ export async function Child (oddCrypto:Crypto, { const newDid = await writeKeyToDid(oddCrypto) const deviceName = await createDeviceName(newDid) + const exchangeKey = await oddCrypto.keystore.publicExchangeKey() /** * Send our DID to the existing device @@ -157,9 +161,7 @@ export async function Child (oddCrypto:Crypto, { deviceName, humanReadableDeviceName, newDid: await writeKeyToDid(oddCrypto), - exchangeKey: toString( - await oddCrypto.keystore.publicExchangeKey() - ) + exchangeKey: toString(exchangeKey) })) return new Promise((resolve, reject) => {