Hierarchy

  • KeyChain

Properties

createKey: ((name: string, type: KeyType, size?: number) => Promise<KeyInfo>)

Type declaration

    • (name: string, type: KeyType, size?: number): Promise<KeyInfo>
    • Create a key in the keychain.

      Example

      const keyInfo = await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
      

      Parameters

      • name: string
      • type: KeyType
      • Optional size: number

      Returns Promise<KeyInfo>

exportKey: ((name: string, password: string) => Promise<Multibase<"m">>)

Type declaration

    • (name: string, password: string): Promise<Multibase<"m">>
    • Export an existing key as a PEM encrypted PKCS #8 string.

      Example

      await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
      const pemKey = await libp2p.keychain.exportKey('keyTest', 'password123')

      Parameters

      • name: string
      • password: string

      Returns Promise<Multibase<"m">>

exportPeerId: ((name: string) => Promise<PeerId>)

Type declaration

    • (name: string): Promise<PeerId>
    • Export an existing key as a PeerId

      Example

      const peerId = await libp2p.keychain.exportPeerId('key-name')
      

      Parameters

      • name: string

      Returns Promise<PeerId>

findKeyById: ((id: string) => Promise<KeyInfo>)

Type declaration

    • (id: string): Promise<KeyInfo>
    • Find a key by it's id.

      Example

      const keyInfo = await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
      const keyInfo2 = await libp2p.keychain.findKeyById(keyInfo.id)

      Parameters

      • id: string

      Returns Promise<KeyInfo>

findKeyByName: ((name: string) => Promise<KeyInfo>)

Type declaration

    • (name: string): Promise<KeyInfo>
    • Find a key by it's name.

      Example

      const keyInfo = await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
      const keyInfo2 = await libp2p.keychain.findKeyByName('keyTest')

      Parameters

      • name: string

      Returns Promise<KeyInfo>

importKey: ((name: string, pem: string, password: string) => Promise<KeyInfo>)

Type declaration

    • (name: string, pem: string, password: string): Promise<KeyInfo>
    • Import a new key from a PEM encoded PKCS #8 string.

      Example

      await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
      const pemKey = await libp2p.keychain.exportKey('keyTest', 'password123')
      const keyInfo = await libp2p.keychain.importKey('keyTestImport', pemKey, 'password123')

      Parameters

      • name: string
      • pem: string
      • password: string

      Returns Promise<KeyInfo>

importPeer: ((name: string, peerId: PeerId) => Promise<KeyInfo>)

Type declaration

    • (name: string, peerId: PeerId): Promise<KeyInfo>
    • Import a new key from a PeerId with a private key component

      Example

      const keyInfo = await libp2p.keychain.importPeer('keyTestImport', peerIdFromString('12D3Foo...'))
      

      Parameters

      Returns Promise<KeyInfo>

listKeys: (() => Promise<KeyInfo[]>)

Type declaration

removeKey: ((name: string) => Promise<KeyInfo>)

Type declaration

    • (name: string): Promise<KeyInfo>
    • Removes a key from the keychain.

      Example

      await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
      const keyInfo = await libp2p.keychain.removeKey('keyTest')

      Parameters

      • name: string

      Returns Promise<KeyInfo>

renameKey: ((oldName: string, newName: string) => Promise<KeyInfo>)

Type declaration

    • (oldName: string, newName: string): Promise<KeyInfo>
    • Rename a key in the keychain.

      Example

      await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
      const keyInfo = await libp2p.keychain.renameKey('keyTest', 'keyNewNtest')

      Parameters

      • oldName: string
      • newName: string

      Returns Promise<KeyInfo>

rotateKeychainPass: ((oldPass: string, newPass: string) => Promise<void>)

Type declaration

    • (oldPass: string, newPass: string): Promise<void>
    • Rotate keychain password and re-encrypt all associated keys

      Example

      await libp2p.keychain.rotateKeychainPass('oldPassword', 'newPassword')
      

      Parameters

      • oldPass: string
      • newPass: string

      Returns Promise<void>