diff --git a/src/claim.js b/src/claim.js index 081e88c..ab5c030 100644 --- a/src/claim.js +++ b/src/claim.js @@ -251,7 +251,7 @@ class Claim { // Post process the data const def = claimDefinitions.data[claimData.serviceprovider.name] - if (def.functions && def.functions.postprocess) { + if (def.functions?.postprocess) { try { ({ claimData, proofData } = def.functions.postprocess(claimData, proofData)) } catch (_) {} diff --git a/src/fetcher/telegram.js b/src/fetcher/telegram.js index eac1b4c..7130f6a 100644 --- a/src/fetcher/telegram.js +++ b/src/fetcher/telegram.js @@ -54,7 +54,7 @@ module.exports.fn = async (data, opts) => { throw new Error(`Telegram fetcher was not set up properly (${err.message})`) } - if (!data.chat || !data.user) { + if (!(data.chat && data.user)) { reject(new Error('Both chat name and user name must be provided')) return } diff --git a/src/keys.js b/src/keys.js index 5fcdba3..bb62e4a 100644 --- a/src/keys.js +++ b/src/keys.js @@ -260,7 +260,7 @@ const fetch = async (identifier) => { * }); */ const process = async (publicKey) => { - if (!publicKey || !(publicKey instanceof openpgp.PublicKey)) { + if (!(publicKey && (publicKey instanceof openpgp.PublicKey))) { throw new Error('Invalid public key') } diff --git a/src/verifications.js b/src/verifications.js index 5059ab1..c92a900 100644 --- a/src/verifications.js +++ b/src/verifications.js @@ -93,7 +93,6 @@ const containsProof = async (data, fingerprint, claimFormat) => { break default: - continue } } } diff --git a/test/keys.test.js b/test/keys.test.js index eb52bd4..b6884c2 100644 --- a/test/keys.test.js +++ b/test/keys.test.js @@ -21,8 +21,8 @@ const path = require('path') const openpgp = require('openpgp') const doipjs = require('../src') -const pubKeyFingerprint = `3637202523e7c1309ab79e99ef2dc5827b445f4b` -const pubKeyEmail = `test@doip.rocks` +const pubKeyFingerprint = "3637202523e7c1309ab79e99ef2dc5827b445f4b" +const pubKeyEmail = "test@doip.rocks" const pubKeyPlaintext = `-----BEGIN PGP PUBLIC KEY BLOCK-----