Skip to content

Commit

Permalink
fix: Send rpc pubkey when sending a message.
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenyoung committed Nov 16, 2024
1 parent 7fd5580 commit 89c7b34
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"dependencies": {
"@chainsafe/libp2p-gossipsub": "^14.1.0",
"@orbitdb/core": "^2.4.0",
"@orbitdb/core": "^2.4.3",
"@orbitdb/set-db": "^1.1.0",
"blockstore-level": "^2.0.1",
"datastore-level": "^11.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/messages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const createRequestMessage = async (type, addresses, identity, signer) =>
const signature = signer
? await signer.sign(JSON.stringify(addresses))
: await identity.sign(identity, JSON.stringify(addresses))
return serialize({ type, id, signature, addresses })
return serialize({ type, id, signature, pubkey: identity.publicKey, addresses })
}

export const createResponseMessage = async (type, message) => {
Expand Down
12 changes: 6 additions & 6 deletions src/rpc-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Commands, sendCommand } from './rpc/index.js'
import { rpc as rpcId, appPath, rpcPath } from './utils/id.js'
import { loadConfig } from './utils/config-manager.js'
import { config as libp2pConfig } from './utils/libp2p-config.js'
import { privateKeyFromProtobuf } from '@libp2p/crypto/keys'
import { privateKeyFromRaw } from '@libp2p/crypto/keys'

const authAdd = (identity, libp2p, address) => async ({ id }) => {
return sendCommand(identity, libp2p, address, Commands.AUTH_ADD, [id])
Expand All @@ -19,7 +19,7 @@ const authList = (identity, libp2p, address) => async () => {
return sendCommand(identity, libp2p, address, Commands.AUTH_LIST)
}

export default async ({ id, directory }) => {
export default async ({ directory }) => {
const appDirectory = appPath(directory)
const rpcDirectory = rpcPath(directory)

Expand All @@ -31,13 +31,13 @@ export default async ({ id, directory }) => {
console.error('No config found. Run daemon first.')
return
}


const id = rpcId
const path = join(rpcDirectory, 'keystore')
const keystore = await KeyStore({ path })
const identities = await Identities({ keystore })
const identity = await identities.createIdentity({ id: rpcId })

const privateKey = privateKeyFromProtobuf((await keystore.getKey(id)).bytes)
const identity = await identities.createIdentity({ id })
const privateKey = privateKeyFromRaw((await keystore.getKey(rpcId)).raw)
const libp2p = await createLibp2p(await libp2pConfig({ privateKey }))

return {
Expand Down

0 comments on commit 89c7b34

Please sign in to comment.