fix!: load self key into keychain on startup if not present (#1357)

To prevent triggering keychain attack prevention on startup, refactor the `KeyChain` class to load the current PeerId as the `'self'` key on startup.

Fixes #1315

BREAKING CHANGE: the `loadKeychain` method has been removed as it is no longer necessary
This commit is contained in:
Alex Potsides
2022-08-17 21:34:57 +01:00
committed by GitHub
parent 29c803a63e
commit 1f38ab7ac8
7 changed files with 27 additions and 65 deletions

View File

@ -9,12 +9,10 @@ import type { Message, PublishResult, PubSubInit, PubSubRPC, PubSubRPCMessage }
import type { Libp2pInit, Libp2pOptions } from '../../src/index.js'
import type { PeerId } from '@libp2p/interface-peer-id'
import * as cborg from 'cborg'
import { peerIdFromString } from '@libp2p/peer-id'
const relayAddr = MULTIADDRS_WEBSOCKETS[0]
export const baseOptions: Partial<Libp2pInit> = {
peerId: peerIdFromString('12D3KooWJKCJW8Y26pRFNv78TCMGLNTfyN8oKaFswMRYXTzSbSst'),
transports: [new WebSockets()],
streamMuxers: [new Mplex()],
connectionEncryption: [new Plaintext()]