From 4c9b96af1a9fb26636f3e7005ec53c888be3fd84 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Thu, 3 Jun 2021 12:48:05 +0200 Subject: [PATCH] Expose key revocation status --- src/keys.js | 7 ++++++- test/keys.test.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/keys.js b/src/keys.js index c4fc203..ace0e6c 100644 --- a/src/keys.js +++ b/src/keys.js @@ -240,15 +240,20 @@ exports.process = (publicKey) => { email: user.userId ? user.userId.email : null, comment: user.userId ? user.userId.comment : null, isPrimary: primaryUser.index === i, + isRevoked: false, }, claims: [], } if ('selfCertifications' in user && user.selfCertifications.length > 0) { - const notations = user.selfCertifications[0].rawNotations + const selfCertification = user.selfCertifications[0] + + const notations = selfCertification.rawNotations usersOutput[i].claims = notations .filter(({ name, humanReadable }) => humanReadable && name === 'proof@metacode.biz') .map(({ value }) => new Claim(openpgp.util.decode_utf8(value)), fingerprint) + + usersOutput[i].userData.isRevoked = selfCertification.revoked } }) diff --git a/test/keys.test.js b/test/keys.test.js index 06f7e33..e4848c3 100644 --- a/test/keys.test.js +++ b/test/keys.test.js @@ -62,6 +62,34 @@ Yn6RMQ8= =Oo3X -----END PGP PUBLIC KEY BLOCK-----` +const pubKeyWithRevokedUID = `-----BEGIN PGP PUBLIC KEY BLOCK----- + +mI0EYLitOQEEAMUKTmcNdy46gjcuz0oRsUyq0BythQGSrcLvLGAyZIzKR8NZXZSA +UAIHuQkWVwqJjYPSRrTp8op8LZIHmhP3W3TgG5WHSOhcPeIYe1JTB0b7XceIIJ3p +/FfT9xFhWgeAVfAHQUcK/p4+mhvQRfDDf5Jbh/i37cY3iF5huNyXZYY9ABEBAAG0 +F1lhcm1vJ3MgU3VwZXIgRXZpbCBUd2luiLYEMAEKACAWIQQKQsh7jbmy9ycMulRn +U1zbmU0aJAUCYLiu7QIdIAAKCRBnU1zbmU0aJGr1A/9VMS9xexufTLHenWCquAsL +cnzciPT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aMCZVqqiVlf9+BxX1rnG6ENseGKPn8Q+RIKUb +Q+AZdYCbM0hdBjP4xdKZcpqak8ksb+aQFXjGacDL/XN4VrP+tBGxkqIqreoDcgIb +7t1hISc09hWrGQ== +=tVW7 +-----END PGP PUBLIC KEY BLOCK-----` describe('keys.fetchURI', () => { it('should be a function (1 argument)', () => { @@ -145,4 +173,11 @@ describe('keys.process', () => { expect(obj.users[0].claims).to.be.lengthOf(1) expect(obj.users[0].claims[0].uri).to.be.equal('dns:yarmo.eu?type=TXT') }) + it('should properly handle revoked UIDs', async () => { + const pubKey = await doipjs.keys.fetchPlaintext(pubKeyWithRevokedUID) + const obj = await doipjs.keys.process(pubKey) + expect(obj.users).to.be.lengthOf(2) + expect(obj.users[0].userData.isRevoked).to.be.true + expect(obj.users[1].userData.isRevoked).to.be.false + }) })