forked from Mirrors/doipjs
Fix old function calls
This commit is contained in:
parent
1a463594dc
commit
c37b4d9cb2
4 changed files with 25 additions and 25 deletions
|
@ -187,14 +187,14 @@ exports.fetchURI = (uri) => {
|
||||||
switch (match[1]) {
|
switch (match[1]) {
|
||||||
case 'hkp':
|
case 'hkp':
|
||||||
resolve(
|
resolve(
|
||||||
fetchHKP(match[3] ? match[3] : match[2], match[3] ? match[2] : null)
|
exports.fetchHKP(match[3] ? match[3] : match[2], match[3] ? match[2] : null)
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
case 'wkd':
|
case 'wkd':
|
||||||
resolve(fetchWKD(match[2]))
|
resolve(exports.fetchWKD(match[2]))
|
||||||
break
|
break
|
||||||
case 'kb':
|
case 'kb':
|
||||||
resolve(fetchKeybase(match[2], match.length >= 4 ? match[3] : null))
|
resolve(exports.fetchKeybase(match[2], match.length >= 4 ? match[3] : null))
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
reject('Invalid URI protocol')
|
reject('Invalid URI protocol')
|
||||||
|
|
|
@ -49,7 +49,7 @@ const process = (signature) => {
|
||||||
try {
|
try {
|
||||||
sigData = await openpgp.cleartext.readArmored(signature)
|
sigData = await openpgp.cleartext.readArmored(signature)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject('invalid_signature')
|
reject(new Error('invalid_signature'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ const process = (signature) => {
|
||||||
if (sigKeys.length > 0) {
|
if (sigKeys.length > 0) {
|
||||||
try {
|
try {
|
||||||
result.key.uri = sigKeys[0]
|
result.key.uri = sigKeys[0]
|
||||||
result.key.data = await keys.fetch.uri(result.key.uri)
|
result.key.data = await keys.fetchURI(result.key.uri)
|
||||||
result.key.fetchMethod = result.key.uri.split(':')[0]
|
result.key.fetchMethod = result.key.uri.split(':')[0]
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ const process = (signature) => {
|
||||||
if (!result.key.data && signersUserId) {
|
if (!result.key.data && signersUserId) {
|
||||||
try {
|
try {
|
||||||
result.key.uri = `wkd:${signersUserId}`
|
result.key.uri = `wkd:${signersUserId}`
|
||||||
result.key.data = await keys.fetch.uri(result.key.uri)
|
result.key.data = await keys.fetchURI(result.key.uri)
|
||||||
result.key.fetchMethod = 'wkd'
|
result.key.fetchMethod = 'wkd'
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
@ -103,10 +103,10 @@ const process = (signature) => {
|
||||||
result.key.uri = `hkp:${match[2]}:${
|
result.key.uri = `hkp:${match[2]}:${
|
||||||
issuerKeyId ? issuerKeyId : signersUserId
|
issuerKeyId ? issuerKeyId : signersUserId
|
||||||
}`
|
}`
|
||||||
result.key.data = await keys.fetch.uri(result.key.uri)
|
result.key.data = await keys.fetchURI(result.key.uri)
|
||||||
result.key.fetchMethod = 'hkp'
|
result.key.fetchMethod = 'hkp'
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject('key_not_found')
|
reject(new Error('key_not_found'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,61 +49,61 @@ x77L7mBkREbuZpFoD/c=
|
||||||
=w7qB
|
=w7qB
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`
|
-----END PGP PUBLIC KEY BLOCK-----`
|
||||||
|
|
||||||
describe('keys.fetch.uri', () => {
|
describe('keys.fetchURI', () => {
|
||||||
it('should be a function (1 argument)', () => {
|
it('should be a function (1 argument)', () => {
|
||||||
expect(doipjs.keys.fetch.uri).to.be.a('function')
|
expect(doipjs.keys.fetchURI).to.be.a('function')
|
||||||
expect(doipjs.keys.fetch.uri).to.have.length(1)
|
expect(doipjs.keys.fetchURI).to.have.length(1)
|
||||||
})
|
})
|
||||||
it('should return a Key object when provided a hkp: uri', async () => {
|
it('should return a Key object when provided a hkp: uri', async () => {
|
||||||
expect(
|
expect(
|
||||||
await doipjs.keys.fetch.uri(`hkp:${pubKeyFingerprint}`)
|
await doipjs.keys.fetchURI(`hkp:${pubKeyFingerprint}`)
|
||||||
).to.be.instanceOf(openpgp.key.Key)
|
).to.be.instanceOf(openpgp.key.Key)
|
||||||
}).timeout('12s')
|
}).timeout('12s')
|
||||||
it('should reject when provided an invalid uri', () => {
|
it('should reject when provided an invalid uri', () => {
|
||||||
return expect(
|
return expect(
|
||||||
doipjs.keys.fetch.uri(`inv:${pubKeyFingerprint}`)
|
doipjs.keys.fetchURI(`inv:${pubKeyFingerprint}`)
|
||||||
).to.eventually.be.rejectedWith('Invalid URI protocol')
|
).to.eventually.be.rejectedWith('Invalid URI protocol')
|
||||||
}).timeout('12s')
|
}).timeout('12s')
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('keys.fetch.hkp', () => {
|
describe('keys.fetchHKP', () => {
|
||||||
it('should be a function (2 arguments)', () => {
|
it('should be a function (2 arguments)', () => {
|
||||||
expect(doipjs.keys.fetch.hkp).to.be.a('function')
|
expect(doipjs.keys.fetchHKP).to.be.a('function')
|
||||||
expect(doipjs.keys.fetch.hkp).to.have.length(2)
|
expect(doipjs.keys.fetchHKP).to.have.length(2)
|
||||||
})
|
})
|
||||||
it('should return a Key object when provided a valid fingerprint', async () => {
|
it('should return a Key object when provided a valid fingerprint', async () => {
|
||||||
expect(await doipjs.keys.fetch.hkp(pubKeyFingerprint)).to.be.instanceOf(
|
expect(await doipjs.keys.fetchHKP(pubKeyFingerprint)).to.be.instanceOf(
|
||||||
openpgp.key.Key
|
openpgp.key.Key
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
it('should return a Key object when provided a valid email address', async () => {
|
it('should return a Key object when provided a valid email address', async () => {
|
||||||
expect(await doipjs.keys.fetch.hkp(pubKeyEmail)).to.be.instanceOf(
|
expect(await doipjs.keys.fetchHKP(pubKeyEmail)).to.be.instanceOf(
|
||||||
openpgp.key.Key
|
openpgp.key.Key
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
it('should reject when provided an invalid fingerprint', async () => {
|
it('should reject when provided an invalid fingerprint', async () => {
|
||||||
return expect(
|
return expect(
|
||||||
doipjs.keys.fetch.hkp('4637202523e7c1309ab79e99ef2dc5827b445f4b')
|
doipjs.keys.fetchHKP('4637202523e7c1309ab79e99ef2dc5827b445f4b')
|
||||||
).to.eventually.be.rejectedWith(
|
).to.eventually.be.rejectedWith(
|
||||||
'Key does not exist or could not be fetched'
|
'Key does not exist or could not be fetched'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
it('should reject when provided an invalid email address', async () => {
|
it('should reject when provided an invalid email address', async () => {
|
||||||
return expect(
|
return expect(
|
||||||
doipjs.keys.fetch.hkp('invalid@doip.rocks')
|
doipjs.keys.fetchHKP('invalid@doip.rocks')
|
||||||
).to.eventually.be.rejectedWith(
|
).to.eventually.be.rejectedWith(
|
||||||
'Key does not exist or could not be fetched'
|
'Key does not exist or could not be fetched'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('keys.fetch.plaintext', () => {
|
describe('keys.fetchPlaintext', () => {
|
||||||
it('should be a function (1 argument)', () => {
|
it('should be a function (1 argument)', () => {
|
||||||
expect(doipjs.keys.fetch.plaintext).to.be.a('function')
|
expect(doipjs.keys.fetchPlaintext).to.be.a('function')
|
||||||
expect(doipjs.keys.fetch.plaintext).to.have.length(1)
|
expect(doipjs.keys.fetchPlaintext).to.have.length(1)
|
||||||
})
|
})
|
||||||
it('should return a Key object', async () => {
|
it('should return a Key object', async () => {
|
||||||
expect(await doipjs.keys.fetch.plaintext(pubKeyPlaintext)).to.be.instanceOf(
|
expect(await doipjs.keys.fetchPlaintext(pubKeyPlaintext)).to.be.instanceOf(
|
||||||
openpgp.key.Key
|
openpgp.key.Key
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@ -115,7 +115,7 @@ describe('keys.process', () => {
|
||||||
expect(doipjs.keys.process).to.have.length(1)
|
expect(doipjs.keys.process).to.have.length(1)
|
||||||
})
|
})
|
||||||
it('should return an object with specific keys', async () => {
|
it('should return an object with specific keys', async () => {
|
||||||
const pubKey = await doipjs.keys.fetch.plaintext(pubKeyPlaintext)
|
const pubKey = await doipjs.keys.fetchPlaintext(pubKeyPlaintext)
|
||||||
const obj = await doipjs.keys.process(pubKey)
|
const obj = await doipjs.keys.process(pubKey)
|
||||||
expect(obj).to.have.keys([
|
expect(obj).to.have.keys([
|
||||||
'users',
|
'users',
|
||||||
|
|
Loading…
Reference in a new issue