GeezerVison is showing docs.openpgpjs.org — JSDoc: Class: Message
Constructor
new Message()
- Source:
Classes
- Message
Methods
appendSignature(detachedSignature) → {Promise.<void>}
Append signature to unencrypted message object
Parameters:
| Name |
Type |
Description |
detachedSignature |
String
|
Uint8Array
|
The detached ASCII-armored or Uint8Array PGP signature |
- Source:
Returns:
-
Type
-
Promise.<void>
(async) appendSignature(detachedSignature, configopt)
Append signature to unencrypted message object
Parameters:
| Name |
Type |
Attributes |
Description |
detachedSignature |
String
|
Uint8Array
|
|
The detached ASCII-armored or Uint8Array PGP signature |
config |
Object
|
<optional>
|
Full configuration, defaults to openpgp.config |
- Source:
armor(configopt) → {string}
Returns ASCII armored text of message
Parameters:
| Name |
Type |
Attributes |
Description |
config |
Config
|
<optional>
|
|
- Source:
Returns:
-
Type
-
string
armor(configopt) → {ReadableStream.<String>}
Returns ASCII armored text of message
Parameters:
| Name |
Type |
Attributes |
Description |
config |
Object
|
<optional>
|
Full configuration, defaults to openpgp.config |
- Source:
Returns:
-
Type
-
ReadableStream.<String>
compress(algo, configopt) → {Message}
Compresses the message (the literal and -if signed- signature data packets of the message)
Parameters:
| Name |
Type |
Attributes |
Description |
algo |
module:enums.compression
|
|
compression algorithm |
config |
Object
|
<optional>
|
Full configuration, defaults to openpgp.config |
- Source:
Returns:
New message with compressed content.
-
Type
-
Message
decrypt(decryptionKeys) → {Promise.<Message.<MaybeStream.<Data>>>}
Parameters:
| Name |
Type |
Description |
decryptionKeys |
|
array of private keys with decrypted secret data |
- Source:
Returns:
-
Type
-
Promise.<Message.<MaybeStream.<Data>>>
(async) decrypt(decryptionKeysopt, passwordsopt, sessionKeysopt, dateopt, configopt) → {Promise.<Message>}
Decrypt the message. Either a private key, a session key, or a password must be specified.
Parameters:
| Name |
Type |
Attributes |
Description |
decryptionKeys |
Array.<PrivateKey>
|
<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] } |
date |
Date
|
<optional>
|
Use the given date for key verification instead of the current time |
config |
Object
|
<optional>
|
Full configuration, defaults to openpgp.config |
- Source:
Returns:
New message with decrypted content.
-
Type
-
Promise.<Message>
(async) decryptSessionKeys(decryptionKeysopt, passwordsopt, expectedSymmetricAlgorithmopt, dateopt, configopt) → {Promise.<Array.<{data: Uint8Array, algorithm: String}>>}
Decrypt encrypted session keys either with private keys or passwords.
Parameters:
| Name |
Type |
Attributes |
Description |
decryptionKeys |
Array.<PrivateKey>
|
<optional>
|
Private keys with decrypted secret data |
passwords |
Array.<String>
|
<optional>
|
Passwords used to decrypt |
expectedSymmetricAlgorithm |
enums.symmetric
|
<optional>
|
The symmetric algorithm the SEIPDv2 / AEAD packet is encrypted with (if applicable) |
date |
Date
|
<optional>
|
Use the given date for key verification, instead of current time |
config |
Object
|
<optional>
|
Full configuration, defaults to openpgp.config |
- Source:
Returns:
array of object with potential sessionKey, algorithm pairs
-
Type
-
Promise.<Array.<{data: Uint8Array, algorithm: String}>>
encrypt(encryptionKeys) → {Promise.<Message.<MaybeStream.<Data>>>}
Parameters:
| Name |
Type |
Description |
encryptionKeys |
|
array of public keys, used to encrypt the message |
- Source:
Returns:
-
Type
-
Promise.<Message.<MaybeStream.<Data>>>
(async) encrypt(encryptionKeysopt, passwordsopt, sessionKeyopt, wildcardopt, encryptionKeyIDsopt, dateopt, userIDsopt, configopt) → {Promise.<Message>}
Encrypt the message either with public keys, passwords, or both at once.
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
encryptionKeys |
Array.<PublicKey>
|
<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>
|
false
|
Use a key ID of 0 instead of the public key IDs |
encryptionKeyIDs |
Array.<module:type/keyid~KeyID>
|
<optional>
|
|
Array of key IDs to use for encryption. Each encryptionKeyIDs[i] corresponds to keys[i] |
date |
Date
|
<optional>
|
|
Override the creation date of the literal package |
userIDs |
Array.<Object>
|
<optional>
|
|
User IDs to encrypt for, e.g. [{ name:'Robert Receiver', email:'[email protected]' }] |
config |
Object
|
<optional>
|
|
Full configuration, defaults to openpgp.config |
- Source:
Returns:
New message with encrypted content.
-
Type
-
Promise.<Message>
getEncryptionKeyIDs() → {Array}
Returns the key IDs of the keys to which the session key is encrypted
- Source:
Returns:
-
Type
-
Array
getEncryptionKeyIDs() → {Array.<module:type/keyid~KeyID>}
Returns the key IDs of the keys to which the session key is encrypted
- Source:
Returns:
-
Type
-
Array.<module:type/keyid~KeyID>
getFilename() → {String|null}
Get filename from literal data packet
- Source:
Returns:
Filename of literal data packet as string.
-
Type
-
String
|
null
getLiteralData() → {StreamedIfStream.<T, Uint8Array>|null}
Get literal data that is the body of the message
- Source:
Returns:
-
Type
-
StreamedIfStream.<T, Uint8Array>
|
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}
Returns the key IDs of the keys that signed the message
- Source:
Returns:
-
Type
-
Array
getSigningKeyIDs() → {Array.<module:type/keyid~KeyID>}
Returns the key IDs of the keys that signed the message
- Source:
Returns:
-
Type
-
Array.<module:type/keyid~KeyID>
getText() → {StreamedIfStream.<T, string>|null}
- Source:
Returns:
-
Type
-
StreamedIfStream.<T, string>
|
null
getText() → {String|null}
- Source:
Returns:
Literal body of the message interpreted as text.
-
Type
-
String
|
null
sign(signingKeys) → {Promise.<Message.<T>>}
Sign the message (the literal data packet of the message)
Parameters:
| Name |
Type |
Description |
signingKeys |
|
private keys with decrypted secret key data for signing |
- Source:
Returns:
-
Type
-
Promise.<Message.<T>>
(async) sign(signingKeys, recipientKeys, signatureopt, signingKeyIDsopt, dateopt, signingUserIDsopt, recipientUserIDsopt, notationsopt, configopt) → {Promise.<Message>}
Sign the message (the literal data packet of the message)
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
signingKeys |
Array.<PrivateKey>
|
|
|
private keys with decrypted secret key data for signing |
recipientKeys |
Array.<Key>
|
|
|
recipient keys to get the signing preferences from |
signature |
Signature
|
<optional>
|
null
|
Any existing detached signature to add to the message |
signingKeyIDs |
Array.<module:type/keyid~KeyID>
|
<optional>
|
|
Array of key IDs to use for signing. Each signingKeyIDs[i] corresponds to signingKeys[i] |
date |
Date
|
<optional>
|
|
Override the creation time of the signature |
signingUserIDs |
Array.<UserID>
|
<optional>
|
|
User IDs to sign with, e.g. [{ name:'Steve Sender', email:'[email protected]' }] |
recipientUserIDs |
Array.<UserID>
|
<optional>
|
|
User IDs associated with recipientKeys to get the signing preferences from |
notations |
Array
|
<optional>
|
|
Notation Data to add to the signatures, e.g. [{ name: '[email protected]', value: new TextEncoder().encode('test'), humanReadable: true, critical: false }] |
config |
Object
|
<optional>
|
|
Full configuration, defaults to openpgp.config |
- Source:
Returns:
New message with signed content.
-
Type
-
Promise.<Message>
(async) signDetached(signingKeys, recipientKeys, signatureopt, signingKeyIDsopt, dateopt, signingUserIDsopt, recipientUserIDsopt, notationsopt, configopt) → {Promise.<Signature>}
Create a detached signature for the message (the literal data packet of the message)
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
signingKeys |
Array.<PrivateKey>
|
|
|
private keys with decrypted secret key data for signing |
recipientKeys |
Array.<Key>
|
|
|
recipient keys to get the signing preferences from |
signature |
Signature
|
<optional>
|
null
|
Any existing detached signature |
signingKeyIDs |
Array.<module:type/keyid~KeyID>
|
<optional>
|
|
Array of key IDs to use for signing. Each signingKeyIDs[i] corresponds to signingKeys[i] |
date |
Date
|
<optional>
|
|
Override the creation time of the signature |
signingUserIDs |
Array.<UserID>
|
<optional>
|
|
User IDs to sign with, e.g. [{ name:'Steve Sender', email:'[email protected]' }] |
recipientUserIDs |
Array.<UserID>
|
<optional>
|
|
User IDs associated with recipientKeys to get the signing preferences from |
notations |
Array
|
<optional>
|
|
Notation Data to add to the signatures, e.g. [{ name: '[email protected]', value: new TextEncoder().encode('test'), humanReadable: true, critical: false }] |
config |
Object
|
<optional>
|
|
Full configuration, defaults to openpgp.config |
- Source:
Returns:
New detached signature of message content.
-
Type
-
Promise.<Signature>
unwrapCompressed() → {Message.<T>}
Unwrap compressed message
- Source:
Returns:
-
Type
-
Message.<T>
unwrapCompressed() → {Message}
Unwrap compressed message
- Source:
Returns:
Message Content of compressed message.
-
Type
-
Message
verify(verificationKeys) → {Promise.<Array>}
Verify message signatures
Parameters:
| Name |
Type |
Description |
verificationKeys |
|
array of public keys to verify signatures |
- Source:
Returns:
-
Type
-
Promise.<Array>
(async) verify(verificationKeys, dateopt, configopt) → {Promise.<Array.<{keyID: module:type/keyid~KeyID, signature: Promise.<Signature>, verified: Promise.<true>}>>}
Verify message signatures
Parameters:
| Name |
Type |
Attributes |
Description |
verificationKeys |
Array.<PublicKey>
|
|
Array of public keys to verify signatures |
date |
Date
|
<optional>
|
Verify the signature against the given date, i.e. check signature creation time < date < expiration time |
config |
Object
|
<optional>
|
Full configuration, defaults to openpgp.config |
- Source:
Returns:
List of signer's keyID and validity of signatures.
-
Type
-
Promise.<Array.<{keyID: module:type/keyid~KeyID, signature: Promise.<Signature>, verified: Promise.<true>}>>
(async) verifyDetached(verificationKeys, signature, date, configopt) → {Promise.<Array.<{keyID: module:type/keyid~KeyID, signature: Promise.<Signature>, verified: Promise.<true>}>>}
Verify detached message signature
Parameters:
| Name |
Type |
Attributes |
Description |
verificationKeys |
Array.<PublicKey>
|
|
Array of public keys to verify signatures |
signature |
Signature
|
|
|
date |
Date
|
|
Verify the signature against the given date, i.e. check signature creation time < date < expiration time |
config |
Object
|
<optional>
|
Full configuration, defaults to openpgp.config |
- Source:
Returns:
List of signer's keyID and validity of signature.
-
Type
-
Promise.<Array.<{keyID: module:type/keyid~KeyID, signature: Promise.<Signature>, verified: Promise.<true>}>>
write() → {MaybeStream.<Uint8Array>}
Returns binary representation of message
- Source:
Returns:
-
Type
-
MaybeStream.<Uint8Array>
write() → {ReadableStream.<Uint8Array>}
Returns binary encoded message
- Source:
Returns:
-
Type
-
ReadableStream.<Uint8Array>
(async, static) encryptSessionKey(sessionKey, algorithmName, aeadAlgorithmNameopt, encryptionKeysopt, passwordsopt, wildcardopt, encryptionKeyIDsopt, dateopt, userIDsopt, configopt) → {Promise.<Message>}
Encrypt a session key either with public keys, passwords, or both at once.
Parameters:
| Name |
Type |
Attributes |
Default |
Description |
sessionKey |
Uint8Array
|
|
|
session key for encryption |
algorithmName |
String
|
|
|
session key algorithm |
aeadAlgorithmName |
String
|
<optional>
|
|
AEAD algorithm, e.g. 'eax' or 'ocb' |
encryptionKeys |
Array.<PublicKey>
|
<optional>
|
|
Public key(s) for message encryption |
passwords |
Array.<String>
|
<optional>
|
|
For message encryption |
wildcard |
Boolean
|
<optional>
|
false
|
Use a key ID of 0 instead of the public key IDs |
encryptionKeyIDs |
Array.<module:type/keyid~KeyID>
|
<optional>
|
|
Array of key IDs to use for encryption. Each encryptionKeyIDs[i] corresponds to encryptionKeys[i] |
date |
Date
|
<optional>
|
|
Override the date |
userIDs |
Array
|
<optional>
|
|
User IDs to encrypt for, e.g. [{ name:'Robert Receiver', email:'[email protected]' }] |
config |
Object
|
<optional>
|
|
Full configuration, defaults to openpgp.config |
- Source:
Returns:
New message with encrypted content.
-
Type
-
Promise.<Message>
(async, static) generateSessionKey(encryptionKeysopt, dateopt, userIDsopt, configopt) → {Promise.<{data: Uint8Array, algorithm: String, aeadAlgorithm: (undefined|String)}>}
Generate a new session key object, taking the algorithm preferences of the passed encryption keys into account, if any.
Parameters:
| Name |
Type |
Attributes |
Description |
encryptionKeys |
Array.<PublicKey>
|
<optional>
|
Public key(s) to select algorithm preferences for |
date |
Date
|
<optional>
|
Date to select algorithm preferences at |
userIDs |
Array.<Object>
|
<optional>
|
User IDs to select algorithm preferences for |
config |
Object
|
<optional>
|
Full configuration, defaults to openpgp.config |
- Source:
Returns:
Object with session key data and algorithms.
-
Type
-
Promise.<{data: Uint8Array, algorithm: String, aeadAlgorithm: (undefined|String)}>
|