forked from Mirrors/doipjs
Fix handling of keys with non-proof notations
This commit is contained in:
parent
ddc80c9380
commit
cd7f3dfd8d
2 changed files with 26 additions and 0 deletions
|
@ -246,6 +246,10 @@ exports.process = (publicKey) => {
|
||||||
|
|
||||||
if ('selfCertifications' in user && user.selfCertifications.length > 0) {
|
if ('selfCertifications' in user && user.selfCertifications.length > 0) {
|
||||||
const notations = user.selfCertifications[0].rawNotations
|
const notations = user.selfCertifications[0].rawNotations
|
||||||
|
usersOutput[i].notations = notations
|
||||||
|
.filter(({ name, humanReadable }) => humanReadable && name === 'proof@metacode.biz')
|
||||||
|
.map(({ value }) => openpgp.util.decode_utf8(value))
|
||||||
|
|
||||||
usersOutput[i].claims = notations.map(
|
usersOutput[i].claims = notations.map(
|
||||||
({ name, value, humanReadable }) => {
|
({ name, value, humanReadable }) => {
|
||||||
if (humanReadable && name === 'proof@metacode.biz') {
|
if (humanReadable && name === 'proof@metacode.biz') {
|
||||||
|
|
|
@ -23,6 +23,7 @@ const doipjs = require('../src')
|
||||||
|
|
||||||
const pubKeyFingerprint = `3637202523e7c1309ab79e99ef2dc5827b445f4b`
|
const pubKeyFingerprint = `3637202523e7c1309ab79e99ef2dc5827b445f4b`
|
||||||
const pubKeyEmail = `test@doip.rocks`
|
const pubKeyEmail = `test@doip.rocks`
|
||||||
|
|
||||||
const pubKeyPlaintext = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
const pubKeyPlaintext = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
|
||||||
mQGNBF+036UBDACoxWRdp7rBAFB2l/+dxX0XA50NJC92EEacB5L0TnC0lP/MsNHv
|
mQGNBF+036UBDACoxWRdp7rBAFB2l/+dxX0XA50NJC92EEacB5L0TnC0lP/MsNHv
|
||||||
|
@ -49,6 +50,19 @@ x77L7mBkREbuZpFoD/c=
|
||||||
=w7qB
|
=w7qB
|
||||||
-----END PGP PUBLIC KEY BLOCK-----`
|
-----END PGP PUBLIC KEY BLOCK-----`
|
||||||
|
|
||||||
|
const pubKeyWithOtherNotations = `-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
|
|
||||||
|
mDMEX9Mt6xYJKwYBBAHaRw8BAQdAch8jfp+8KHH5cy/t45GjPvl6dkEv2soIy9fo
|
||||||
|
Oe9DbP20EVlhcm1vJ3MgRXZpbCBUd2luiNsEExYIAIMCGwMFCwkIBwIGFQoJCAsC
|
||||||
|
BBYCAwECHgECF4AWIQTeePcduHH8EU2iM3aw5zJVrULhnwUCX9MuHBkUgAAAAAAN
|
||||||
|
AANldmlsQHlhcm1vLmV1eWVzMBSAAAAAABIAFXByb29mQG1ldGFjb2RlLmJpemRu
|
||||||
|
czp5YXJtby5ldT90eXBlPVRYVAAKCRCw5zJVrULhn4DtAQCVkyI8UxUbkxspXkWB
|
||||||
|
qUL+3uqCl9gTbNImhv/OxxJdEAEAqf8SJ9FSeAwgWhPHOidR1m+J6/qVdAJdp0HJ
|
||||||
|
Yn6RMQ8=
|
||||||
|
=Oo3X
|
||||||
|
-----END PGP PUBLIC KEY BLOCK-----`
|
||||||
|
|
||||||
|
|
||||||
describe('keys.fetchURI', () => {
|
describe('keys.fetchURI', () => {
|
||||||
it('should be a function (1 argument)', () => {
|
it('should be a function (1 argument)', () => {
|
||||||
expect(doipjs.keys.fetchURI).to.be.a('function')
|
expect(doipjs.keys.fetchURI).to.be.a('function')
|
||||||
|
@ -124,4 +138,12 @@ describe('keys.process', () => {
|
||||||
'key',
|
'key',
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
it('should ignore non-proof notations', async () => {
|
||||||
|
const pubKey = await doipjs.keys.fetchPlaintext(pubKeyWithOtherNotations)
|
||||||
|
const obj = await doipjs.keys.process(pubKey)
|
||||||
|
console.log(obj.users[0]);
|
||||||
|
expect(obj.users).to.be.lengthOf(1)
|
||||||
|
expect(obj.users[0].notations).to.be.lengthOf(1)
|
||||||
|
expect(obj.users[0].notations[0]).to.be.equal('dns:yarmo.eu?type=TXT')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue