|
|
@ -1,6 +1,6 @@
|
|
|
|
|
|
|
|
import crypto from 'crypto';
|
|
|
|
import * as openpgp from 'openpgp';
|
|
|
|
import * as openpgp from 'openpgp';
|
|
|
|
import { Transform, TransformCallback } from 'stream';
|
|
|
|
import { Transform, TransformCallback } from 'stream';
|
|
|
|
import crypto from 'crypto';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface EncryptorOptions {
|
|
|
|
interface EncryptorOptions {
|
|
|
|
signingKey?: string;
|
|
|
|
signingKey?: string;
|
|
|
@ -54,7 +54,8 @@ class PGPEncryptor extends Transform {
|
|
|
|
privateKey = await openpgp.readKey({
|
|
|
|
privateKey = await openpgp.readKey({
|
|
|
|
armoredKey: this._signingKey,
|
|
|
|
armoredKey: this._signingKey,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
await privateKey.decrypt(this._password);
|
|
|
|
|
|
|
|
|
|
|
|
await openpgp.decryptKey({ privateKey, passphrase: this._password });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const emailPartDelimiter = '\r\n\r\n';
|
|
|
|
const emailPartDelimiter = '\r\n\r\n';
|
|
|
@ -128,11 +129,12 @@ class PGPEncryptor extends Transform {
|
|
|
|
.join('\r\n');
|
|
|
|
.join('\r\n');
|
|
|
|
|
|
|
|
|
|
|
|
const encryptedMessage = await openpgp.encrypt({
|
|
|
|
const encryptedMessage = await openpgp.encrypt({
|
|
|
|
message: openpgp.Message.fromText(
|
|
|
|
message: await openpgp.createMessage({
|
|
|
|
contentHeadersRaw +
|
|
|
|
text:
|
|
|
|
|
|
|
|
contentHeadersRaw +
|
|
|
|
emailPartDelimiter +
|
|
|
|
emailPartDelimiter +
|
|
|
|
messageParts.join(emailPartDelimiter)
|
|
|
|
messageParts.join(emailPartDelimiter),
|
|
|
|
),
|
|
|
|
}),
|
|
|
|
publicKeys: validPublicKeys,
|
|
|
|
publicKeys: validPublicKeys,
|
|
|
|
privateKeys: privateKey,
|
|
|
|
privateKeys: privateKey,
|
|
|
|
});
|
|
|
|
});
|
|
|
|