Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix: remove http api support for key.export
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobheun committed Aug 5, 2020
1 parent 2f89e87 commit 782235e
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 159 deletions.
37 changes: 0 additions & 37 deletions packages/interface-ipfs-core/src/key/export.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/interface-ipfs-core/src/key/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const tests = {
list: require('./list'),
rename: require('./rename'),
rm: require('./rm'),
export: require('./export'),
import: require('./import')
}

Expand Down
26 changes: 0 additions & 26 deletions packages/ipfs-http-client/src/key/export.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/ipfs-http-client/src/key/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ module.exports = config => ({
list: require('./list')(config),
rename: require('./rename')(config),
rm: require('./rm')(config),
export: require('./export')(config),
import: require('./import')(config)
})
44 changes: 0 additions & 44 deletions packages/ipfs/src/http/api/resources/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,50 +181,6 @@ exports.gen = {
}
}

exports.export = {
options: {
validate: {
options: {
allowUnknown: true,
stripUnknown: true
},
query: Joi.object().keys({
name: Joi.string().required(),
password: Joi.string().required(),
timeout: Joi.timeout()
})
.rename('arg', 'name', {
override: true,
ignoreUndefined: true
})
}
},
handler: async (request, h) => {
const {
app: {
signal
},
server: {
app: {
ipfs
}
},
query: {
name,
password,
timeout
}
} = request

const pem = await ipfs.key.export(name, password, {
signal,
timeout
})

return h.response(pem).type('application/x-pem-file')
}
}

exports.import = {
options: {
validate: {
Expand Down
5 changes: 0 additions & 5 deletions packages/ipfs/src/http/api/routes/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ module.exports = [
path: '/api/v0/key/rename',
...resources.key.rename
},
{
method: 'POST',
path: '/api/v0/key/export',
...resources.key.export
},
{
method: 'POST',
path: '/api/v0/key/import',
Expand Down
45 changes: 0 additions & 45 deletions packages/ipfs/test/http-api/inject/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ describe('/key', function () {
rm: sinon.stub(),
rename: sinon.stub(),
gen: sinon.stub(),
export: sinon.stub(),
import: sinon.stub()
}
}
Expand Down Expand Up @@ -228,50 +227,6 @@ describe('/key', function () {
})
})

describe('/export', () => {
const defaultOptions = {
signal: sinon.match.instanceOf(AbortSignal),
timeout: undefined
}

it('only accepts POST', () => {
return testHttpMethod('/api/v0/key/export')
})

it('should export a key', async () => {
const name = 'name'
const password = 'password'

ipfs.key.export.withArgs(name, password, defaultOptions).returns('pem')

const res = await http({
method: 'POST',
url: `/api/v0/key/export?arg=${name}&password=${password}`
}, { ipfs })

expect(res).to.have.property('statusCode', 200)
expect(res).to.have.property('result', 'pem')
})

it('accepts a timeout', async () => {
const name = 'name'
const password = 'password'

ipfs.key.export.withArgs(name, password, {
...defaultOptions,
timeout: 1000
}).returns('pem')

const res = await http({
method: 'POST',
url: `/api/v0/key/export?arg=${name}&password=${password}&timeout=1s`
}, { ipfs })

expect(res).to.have.property('statusCode', 200)
expect(res).to.have.property('result', 'pem')
})
})

describe('/import', () => {
const defaultOptions = {
signal: sinon.match.instanceOf(AbortSignal),
Expand Down

0 comments on commit 782235e

Please sign in to comment.