Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
detached: true
}).then(s => s.signature/* as openpgp.signature.Signature*/);
openpgp.sign({
message: null,
privateKeys: [],
armor: false,
detached: false,
}).then(s => s.message/* as openpgp.message.Message*/);
const verifyOptions: openpgp.VerifyOptions = {
message,
signature,
publicKeys: publicKey.keys
};
const verified = await openpgp.verify(verifyOptions);
return verified.signatures[0].valid;
})();
return new Promise((resolve) => {
openpgp.verify(options).then((verified) => {
const validity = verified.signatures[0].valid; // true
resolve(validity);
});
});
};
const verifyDetached = async (message, detachedSig, publicKey) => {
const options = {
message: openpgp.cleartext.fromText(message), // CleartextMessage or Message object
signature: await openpgp.signature.readArmored(detachedSig), // parse detached signature
publicKeys: (await openpgp.key.readArmored(publicKey)).keys, // for verification
};
const verified = await openpgp.verify(options);
const validity = verified.signatures[0].valid; // true
return validity;
};
return Promise.resolve().then(()=>{
let options = {
message: openpgp.cleartext.readArmored(armoredText), // parse armored message
publicKeys: openpgp.key.readArmored(keyText).keys // for verification
};
return openpgp.verify(options).then((verified)=>{
return {options, verified};
});
}).catch((error)=>{
return {
const attemptVerify = (rawPublicKeys) => __awaiter(this, void 0, void 0, function* () {
try {
const publicKeys = openpgp.key.readArmored(rawPublicKeys).keys;
const verifyOptions = {
message: openpgp.message.fromText(deterministicSignature),
signature: openpgp.signature.readArmored(signature),
publicKeys: publicKeys
};
const verifiedMessage = yield openpgp.verify(verifyOptions);
return verifiedMessage.signatures.length >= 1;
}
catch (e) {
return false;
}
});
let urlHashObj = crypto.createHash('sha512');
static async verify (email, msg) {
const publicKeys = locallookup(email)
const verified = await openpgp.verify({
publicKeys: publicKeys,
message: openpgp.cleartext.readArmored(msg)
})
let signature = verified.signatures.map(getFullSignature)
signature = signature.filter(x => x.email === email)
if (signature.length !== 1) {
return false
} else {
return signature[0].valid
}
}
const attemptVerify = async (rawPublicKeys: string) => {
try {
const publicKeys = (await openpgp.key.readArmored(rawPublicKeys)).keys;
const verifyOptions = {
message: openpgp.message.fromText(deterministicString),
signature: await openpgp.signature.readArmored(signature),
publicKeys: publicKeys
};
const verifiedMessage = await openpgp.verify(verifyOptions);
return verifiedMessage.signatures.length >= 1;
} catch (e) {
return false;
}
};
return reject(new Error('Missing signed message'));
}
if (pubKeys === undefined || pubKeys.length < 1) {
return reject(new Error('Missing public keys'));
}
const message = openpgp.cleartext.readArmored(signedMessage.trim());
if (message instanceof Error) return reject(message);
const options = {
message: message,
publicKeys: pubKeys,
};
openpgp.verify(options).then((signedMsg) => {
resolve(signedMsg);
}).catch(function(err) {
reject('Message verification failed');
});
});
}
const content = new Minimize({ spare:true, conditionals: true, empty: true, quotes: true }).parse(rawContent)
.replace(/^\s*]*>/i, '');
const shouldCheck = getPubkey(patterns, url);
if (shouldCheck) {
try {
const pubkey = patterns[shouldCheck];
const options = {
message: openpgp.message.fromBinary(openpgp.util.str2Uint8Array(content)),
signature: openpgp.signature.readArmored(signature),
publicKeys: openpgp.key.readArmored(pubkey).keys,
};
openpgp.verify(options).then((verified) => {
const signatureData = (verified.signatures[0].valid) ? goodSignature : badSignature;
updateBrowserAction(signatureData, tabId);
statusCache[url] = signatureData;
});
} catch (e) {
updateBrowserAction(badSignature, tabId);
statusCache[url] = badSignature;
}
} else {
updateBrowserAction(neutralSignature, tabId);
}
}
const attemptVerify = (rawPublicKeys) => __awaiter(this, void 0, void 0, function* () {
try {
const publicKeys = openpgp.key.readArmored(rawPublicKeys).keys;
const verifyOptions = {
message: openpgp.message.fromText(deterministicSignature),
signature: openpgp.signature.readArmored(signature),
publicKeys: publicKeys
};
const verifiedMessage = yield openpgp.verify(verifyOptions);
return verifiedMessage.signatures.length >= 1;
}
catch (e) {
return false;
}
});
let rawPublicKeys = yield this.trustStore.getOrFetchCachedPublicKeys('keybase.io.' + identity.keybaseUser, fetchPub);