mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-10-14 00:59:29 +00:00
Appease linter
This commit is contained in:
parent
33af3debc4
commit
21343f2bb8
@ -128,24 +128,21 @@ function verifyHeaders(headers) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Splits a message into two parts, the body and the checksum. This is an internal function
|
* Remove the (optional) checksum from an armored message.
|
||||||
* @param {String} text - OpenPGP armored message part
|
* @param {String} text - OpenPGP armored message
|
||||||
* @returns {Object} An object with attribute "body" containing the body.
|
* @returns {String} The body of the armored message.
|
||||||
* and an attribute "checksum" containing the checksum.
|
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function splitChecksum(text) {
|
function removeChecksum(text) {
|
||||||
let body = text;
|
let body = text;
|
||||||
let checksum = '';
|
|
||||||
|
|
||||||
const lastEquals = text.lastIndexOf('=');
|
const lastEquals = text.lastIndexOf('=');
|
||||||
|
|
||||||
if (lastEquals >= 0 && lastEquals !== text.length - 1) { // '=' as the last char means no checksum
|
if (lastEquals >= 0 && lastEquals !== text.length - 1) { // '=' as the last char means no checksum
|
||||||
body = text.slice(0, lastEquals);
|
body = text.slice(0, lastEquals);
|
||||||
checksum = text.slice(lastEquals + 1).substr(0, 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { body: body, checksum: checksum };
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,7 +154,7 @@ function splitChecksum(text) {
|
|||||||
* @async
|
* @async
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
export function unarmor(input, config = defaultConfig) {
|
export function unarmor(input) {
|
||||||
// eslint-disable-next-line no-async-promise-executor
|
// eslint-disable-next-line no-async-promise-executor
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
@ -170,8 +167,7 @@ export function unarmor(input, config = defaultConfig) {
|
|||||||
let headersDone;
|
let headersDone;
|
||||||
let text = [];
|
let text = [];
|
||||||
let textDone;
|
let textDone;
|
||||||
let checksum;
|
const data = base64.decode(stream.transformPair(input, async (readable, writable) => {
|
||||||
let data = base64.decode(stream.transformPair(input, async (readable, writable) => {
|
|
||||||
const reader = stream.getReader(readable);
|
const reader = stream.getReader(readable);
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -236,9 +232,8 @@ export function unarmor(input, config = defaultConfig) {
|
|||||||
if (parts.length === 1) {
|
if (parts.length === 1) {
|
||||||
throw new Error('Misformed armored text');
|
throw new Error('Misformed armored text');
|
||||||
}
|
}
|
||||||
const split = splitChecksum(parts[0].slice(0, -1));
|
const body = removeChecksum(parts[0].slice(0, -1));
|
||||||
checksum = split.checksum;
|
await writer.write(body);
|
||||||
await writer.write(split.body);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,8 +245,8 @@ export class Message {
|
|||||||
const serialisedPKESK = pkeskPacket.write(); // make copies to be able to decrypt the PKESK packet multiple times
|
const serialisedPKESK = pkeskPacket.write(); // make copies to be able to decrypt the PKESK packet multiple times
|
||||||
await Promise.all((
|
await Promise.all((
|
||||||
expectedSymmetricAlgorithm ?
|
expectedSymmetricAlgorithm ?
|
||||||
[expectedSymmetricAlgorithm] :
|
[expectedSymmetricAlgorithm] :
|
||||||
Array.from(config.constantTimePKCS1DecryptionSupportedSymmetricAlgorithms)
|
Array.from(config.constantTimePKCS1DecryptionSupportedSymmetricAlgorithms)
|
||||||
).map(async sessionKeyAlgorithm => {
|
).map(async sessionKeyAlgorithm => {
|
||||||
const pkeskPacketCopy = new PublicKeyEncryptedSessionKeyPacket();
|
const pkeskPacketCopy = new PublicKeyEncryptedSessionKeyPacket();
|
||||||
pkeskPacketCopy.read(serialisedPKESK);
|
pkeskPacketCopy.read(serialisedPKESK);
|
||||||
|
@ -37,7 +37,7 @@ class PaddingPacket {
|
|||||||
* Read a padding packet
|
* Read a padding packet
|
||||||
* @param {Uint8Array | ReadableStream<Uint8Array>} bytes
|
* @param {Uint8Array | ReadableStream<Uint8Array>} bytes
|
||||||
*/
|
*/
|
||||||
read(bytes) {
|
read(bytes) { // eslint-disable-line no-unused-vars
|
||||||
// Padding packets are ignored, so this function is never called.
|
// Padding packets are ignored, so this function is never called.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ class SymEncryptedIntegrityProtectedDataPacket {
|
|||||||
this.version = await reader.readByte();
|
this.version = await reader.readByte();
|
||||||
// - A one-octet version number with value 1 or 2.
|
// - A one-octet version number with value 1 or 2.
|
||||||
if (this.version !== 1 && this.version !== 2) {
|
if (this.version !== 1 && this.version !== 2) {
|
||||||
throw new UnsupportedError(`Version ${version} of the SEIP packet is unsupported.`);
|
throw new UnsupportedError(`Version ${this.version} of the SEIP packet is unsupported.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.version === 2) {
|
if (this.version === 2) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user