ipfs-http-client
Version:
A client library for the IPFS HTTP API
35 lines (30 loc) • 869 B
JavaScript
const toCamel = require('../lib/object-to-camel')
const configure = require('../lib/configure')
const toUrlSearchParams = require('../lib/to-url-search-params')
/**
* @typedef {import('../types').HTTPClientExtraOptions} HTTPClientExtraOptions
* @typedef {import('ipfs-core-types/src/key').API<HTTPClientExtraOptions>} KeyAPI
*/
module.exports = configure(api => {
/**
* @type {KeyAPI["rename"]}
*/
async function rename (oldName, newName, options = {}) {
const res = await api.post('key/rename', {
timeout: options.timeout,
signal: options.signal,
searchParams: toUrlSearchParams({
arg: [
oldName,
newName
],
...options
}),
headers: options.headers
})
// @ts-ignore server output is not typed
return toCamel(await res.json())
}
return rename
})