Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface API<OptionExtension>

Type parameters

  • OptionExtension = {}

Hierarchy

  • API

Index

Methods

  • export(name: string, password: string, options?: AbortOptions & OptionExtension): Promise<string>
  • Remove a key

    example
    const pem = await ipfs.key.export('self', 'password')

    console.log(pem)
    // -----BEGIN ENCRYPTED PRIVATE KEY-----
    // MIIFDTA/BgkqhkiG9w0BBQ0wMjAaBgkqhkiG9w0BBQwwDQQIpdO40RVyBwACAWQw
    // ...
    // YA==
    // -----END ENCRYPTED PRIVATE KEY-----

    Parameters

    • name: string
    • password: string
    • Optional options: AbortOptions & OptionExtension

    Returns Promise<string>

  • gen(name: string, options?: GenOptions & OptionExtension): Promise<Key>
  • Generate a new key

    example
    const key = await ipfs.key.gen('my-key', {
    type: 'rsa',
    size: 2048
    })

    console.log(key)
    // { id: 'QmYWqAFvLWb2G5A69JGXui2JJXzaHXiUEmQkQgor6kNNcJ',
    // name: 'my-key' }

    Parameters

    • name: string
    • Optional options: GenOptions & OptionExtension

    Returns Promise<Key>

  • import(name: string, pem: string, password: string, options?: AbortOptions & OptionExtension): Promise<Key>
  • Remove a key

    example
    const key = await ipfs.key.import('clone', pem, 'password')

    console.log(key)
    // { id: 'QmQRiays958UM7norGRQUG3tmrLq8pJdmJarwYSk2eLthQ',
    // name: 'clone' }

    Parameters

    • name: string
    • pem: string
    • password: string
    • Optional options: AbortOptions & OptionExtension

    Returns Promise<Key>

  • Return the id and name of a key

    • @example
      const { id, name } = await ipfs.key.info('key-name')
      

    Parameters

    • name: string
    • Optional options: AbortOptions & OptionExtension

    Returns Promise<Key>

  • List all the keys

    example
    const keys = await ipfs.key.list()

    console.log(keys)
    // [
    // { id: 'QmTe4tuceM2sAmuZiFsJ9tmAopA8au71NabBDdpPYDjxAb',
    // name: 'self' },
    // { id: 'QmWETF5QvzGnP7jKq5sPDiRjSM2fzwzNsna4wSBEzRzK6W',
    // name: 'my-key' }
    // ]

    Parameters

    Returns Promise<Key[]>

  • Rename a key

    example
    const key = await ipfs.key.rename('my-key', 'my-new-key')

    console.log(key)
    // { id: 'Qmd4xC46Um6s24MradViGLFtMitvrR4SVexKUgPgFjMNzg',
    // was: 'my-key',
    // now: 'my-new-key',
    // overwrite: false }

    Parameters

    • oldName: string
    • newName: string
    • Optional options: AbortOptions & OptionExtension

    Returns Promise<RenameKeyResult>

  • Remove a key

    example
    const key = await ipfs.key.rm('my-key')

    console.log(key)
    // { id: 'QmWETF5QvzGnP7jKq5sPDiRjSM2fzwzNsna4wSBEzRzK6W',
    // name: 'my-key' }

    Parameters

    • name: string
    • Optional options: AbortOptions & OptionExtension

    Returns Promise<Key>

Generated using TypeDoc