fixes
This commit is contained in:
parent
11a8a99aef
commit
b310877c7d
|
@ -170,6 +170,15 @@ Message.prototype.getLiteralData = function() {
|
|||
return literal && literal.data || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get filename from literal data packet
|
||||
* @return {(String|null)} filename of literal data packet as string
|
||||
*/
|
||||
Message.prototype.getFilename = function() {
|
||||
var literal = this.packets.findPacket(enums.packet.literal);
|
||||
return literal && literal.getFilename() || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get literal data as text
|
||||
* @return {(String|null)} literal body of the message interpreted as text
|
||||
|
|
|
@ -105,11 +105,12 @@ function encryptMessage(keys, data, passwords, params) {
|
|||
msg = msg.encrypt(keys, passwords);
|
||||
|
||||
if(packets) {
|
||||
var arr = [];
|
||||
var dataIndex = msg.packets.indexOfTag(enums.packet.symmetricallyEncrypted, enums.packet.symEncryptedIntegrityProtected)[0];
|
||||
arr.push(msg.packets.slice(0,dataIndex).write()); // Keys
|
||||
arr.push(msg.packets.slice(dataIndex,msg.packets.length).write()); // Data
|
||||
return arr;
|
||||
var obj = {
|
||||
keys: msg.packets.slice(0,dataIndex).write(),
|
||||
data: msg.packets.slice(dataIndex,msg.packets.length).write()
|
||||
};
|
||||
return obj;
|
||||
}
|
||||
else {
|
||||
return armor.encode(enums.armor.message, msg.packets.write());
|
||||
|
@ -195,7 +196,7 @@ function decryptMessage(privateKey, msg, params) {
|
|||
if(binary) {
|
||||
var obj = {
|
||||
data: msg.getLiteralData(),
|
||||
filename: msg.filename
|
||||
filename: msg.getFilename()
|
||||
};
|
||||
return obj;
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ describe('Basic', function() {
|
|||
openpgp.encryptMessage([pubKey], plaintext, [password1, password2], params).then(function(encrypted) {
|
||||
|
||||
expect(encrypted).to.exist;
|
||||
encrypted = encrypted.join('');
|
||||
encrypted = encrypted.keys+encrypted.data;
|
||||
encrypted = openpgp.armor.encode(openpgp.enums.armor.message, encrypted);
|
||||
message = openpgp.message.readArmored(encrypted);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user