From f88f4d5d2e9dcf533482b0d750fddf51cf6c1ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Obernd=C3=B6rfer?= Date: Wed, 13 Mar 2019 11:18:20 +0100 Subject: [PATCH] Replace addressparser with openpgp.util.parseUserId --- package-lock.json | 5 ----- package.json | 1 - src/service/pgp.js | 23 ++++++++++++----------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1c61cb3..3cfec0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -94,11 +94,6 @@ "email-addresses": "^3.0.0" } }, - "addressparser": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/addressparser/-/addressparser-1.0.1.tgz", - "integrity": "sha1-R6++GiqSYhkdtoOOT9HTm0CCF0Y=" - }, "ajv": { "version": "6.9.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.9.2.tgz", diff --git a/package.json b/package.json index a04b56a..e6d9968 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "release:archive": "zip -rq release.zip package.json package-lock.json node_modules/ *.js src/ config/" }, "dependencies": { - "addressparser": "1.0.1", "co-body": "6.0.0", "config": "3.0.1", "koa": "2.7.0", diff --git a/src/service/pgp.js b/src/service/pgp.js index 92d32d5..589f3f9 100644 --- a/src/service/pgp.js +++ b/src/service/pgp.js @@ -20,7 +20,6 @@ const log = require('winston'); const util = require('./util'); const openpgp = require('openpgp'); -const addressparser = require('addressparser'); const KEY_BEGIN = '-----BEGIN PGP PUBLIC KEY BLOCK-----'; const KEY_END = '-----END PGP PUBLIC KEY BLOCK-----'; @@ -131,16 +130,18 @@ class PGP { for (const user of users) { const userStatus = await user.verify(primaryKey, verifyDate); if (userStatus !== openpgp.enums.keyStatus.invalid && user.userId && user.userId.userid) { - const uid = addressparser(user.userId.userid)[0]; - if (util.isEmail(uid.address)) { - // map to local user id object format - result.push({ - status: userStatus, - name: uid.name, - email: util.normalizeEmail(uid.address), - verified: false - }); - } + try { + const uid = openpgp.util.parseUserId(user.userId.userid); + if (util.isEmail(uid.email)) { + // map to local user id object format + result.push({ + status: userStatus, + name: uid.name, + email: util.normalizeEmail(uid.email), + verified: false + }); + } + } catch (e) {} } } return result;