Class: Message

message.Message(packetlist)

Class that represents an OpenPGP message. Can be an encrypted message, signed message, compressed message or literal message

Constructor

new Message(packetlist)

Parameters:
Name Type Description
packetlist module:packet.List

The packets that form this message See https://tools.ietf.org/html/rfc4880#section-11.3

Source:

Methods

appendSignature(detachedSignature)

Append signature to unencrypted message object

Parameters:
Name Type Description
detachedSignature String | Uint8Array

The detached ASCII-armored or Uint8Array PGP signature

Source:

armor() → {ReadableStream.<String>}

Returns ASCII armored text of message

Source:
Returns:

ASCII armor

Type
ReadableStream.<String>

compress(compression) → {module:message.Message}

Compresses the message (the literal and -if signed- signature data packets of the message)

Parameters:
Name Type Description
compression module:enums.compression

compression algorithm to be used

Source:
Returns:

new message with compressed content

Type
module:message.Message

(async) decrypt(privateKeys, passwords, sessionKeys, streaming) → {Promise.<Message>}

Decrypt the message. Either a private key, a session key, or a password must be specified.

Parameters:
Name Type Description
privateKeys Array.<Key>

(optional) private keys with decrypted secret data

passwords Array.<String>

(optional) passwords used to decrypt

sessionKeys Array.<Object>

(optional) session keys in the form: { data:Uint8Array, algorithm:String, [aeadAlgorithm:String] }

streaming Boolean

(optional) whether to process data as a stream

Source:
Returns:

new message with decrypted content

Type
Promise.<Message>

(async) decryptSessionKeys(privateKeys, passwords) → {Promise.<Array.<{data: Uint8Array, algorithm: String}>>}

Decrypt encrypted session keys either with private keys or passwords.

Parameters:
Name Type Description
privateKeys Array.<Key>

(optional) private keys with decrypted secret data

passwords Array.<String>

(optional) passwords used to decrypt

Source:
Returns:

array of object with potential sessionKey, algorithm pairs

Type
Promise.<Array.<{data: Uint8Array, algorithm: String}>>

(async) encrypt(keys, passwords, sessionKey, wildcard, date, userId, streaming) → {Promise.<Message>}

Encrypt the message either with public keys, passwords, or both at once.

Parameters:
Name Type Description
keys Array.<Key>

(optional) public key(s) for message encryption

passwords Array.<String>

(optional) password(s) for message encryption

sessionKey Object

(optional) session key in the form: { data:Uint8Array, algorithm:String, [aeadAlgorithm:String] }

wildcard Boolean

(optional) use a key ID of 0 instead of the public key IDs

date Date

(optional) override the creation date of the literal package

userId Object

(optional) user ID to encrypt for, e.g. { name:'Robert Receiver', email:'[email protected]' }

streaming Boolean

(optional) whether to process data as a stream

Source:
Returns:

new message with encrypted content

Type
Promise.<Message>

getEncryptionKeyIds() → {Array.<module:type/keyid>}

Returns the key IDs of the keys to which the session key is encrypted

Source:
Returns:

array of keyid objects

Type
Array.<module:type/keyid>

getFilename() → {String|null}

Get filename from literal data packet

Source:
Returns:

filename of literal data packet as string

Type
String | null

getLiteralData() → {Uint8Array|null}

Get literal data that is the body of the message

Source:
Returns:

literal body of the message as Uint8Array

Type
Uint8Array | null

getSigningKeyIds() → {Array.<module:type/keyid>}

Returns the key IDs of the keys that signed the message

Source:
Returns:

array of keyid objects

Type
Array.<module:type/keyid>

getText() → {String|null}

Get literal data as text

Source:
Returns:

literal body of the message interpreted as text

Type
String | null

(async) sign(privateKeys, signature, date, userId) → {Promise.<Message>}

Sign the message (the literal data packet of the message)

Parameters:
Name Type Description
privateKeys Array.<module:key.Key>

private keys with decrypted secret key data for signing

signature Signature

(optional) any existing detached signature to add to the message

date Date

(optional) override the creation time of the signature

userId Object

(optional) user ID to sign with, e.g. { name:'Steve Sender', email:'[email protected]' }

Source:
Returns:

new message with signed content

Type
Promise.<Message>

(async) signDetached(privateKeys, signature, date, userId) → {Promise.<module:signature.Signature>}

Create a detached signature for the message (the literal data packet of the message)

Parameters:
Name Type Description
privateKeys Array.<module:key.Key>

private keys with decrypted secret key data for signing

signature Signature

(optional) any existing detached signature

date Date

(optional) override the creation time of the signature

userId Object

(optional) user ID to sign with, e.g. { name:'Steve Sender', email:'[email protected]' }

Source:
Returns:

new detached signature of message content

Type
Promise.<module:signature.Signature>

unwrapCompressed() → {module:message.Message}

Unwrap compressed message

Source:
Returns:

message Content of compressed message

Type
module:message.Message

(async) verify(keys, date, streaming) → {Promise.<Array.<({keyid: module:type/keyid, valid: Boolean})>>}

Verify message signatures

Parameters:
Name Type Description
keys Array.<module:key.Key>

array of keys to verify signatures

date Date

(optional) Verify the signature against the given date, i.e. check signature creation time < date < expiration time

streaming Boolean

(optional) whether to process data as a stream

Source:
Returns:

list of signer's keyid and validity of signature

Type
Promise.<Array.<({keyid: module:type/keyid, valid: Boolean})>>

(async) verifyDetached(keys, signature, date) → {Promise.<Array.<({keyid: module:type/keyid, valid: Boolean})>>}

Verify detached message signature

Parameters:
Name Type Description
keys Array.<module:key.Key>

array of keys to verify signatures

signature Signature
date Date

Verify the signature against the given date, i.e. check signature creation time < date < expiration time

Source:
Returns:

list of signer's keyid and validity of signature

Type
Promise.<Array.<({keyid: module:type/keyid, valid: Boolean})>>