Replace addressparser with openpgp.util.parseUserId
This commit is contained in:
parent
b83f13cde2
commit
f88f4d5d2e
5
package-lock.json
generated
5
package-lock.json
generated
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user