Skip to content

Commit

Permalink
works in manual test
Browse files Browse the repository at this point in the history
  • Loading branch information
nichoth committed Apr 21, 2024
1 parent 25c02b8 commit 17741cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 8 additions & 3 deletions example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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) => {
Expand Down

0 comments on commit 17741cf

Please sign in to comment.