Methods
armor(messageType, body, partIndexopt, partTotalopt, customCommentopt) → {String|ReadableStream.<String>}
Armor an OpenPGP binary packet block
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
messageType |
module:enums.armor | Type of the message |
|
body |
Uint8Array | ReadableStream.<Uint8Array> | The message body to armor |
|
partIndex |
Integer |
<optional> |
|
partTotal |
Integer |
<optional> |
|
customComment |
String |
<optional> |
Additional comment to add to the armored string |
- Source:
Returns:
Armored text.
- Type
- String | ReadableStream.<String>
(async) createCleartextMessage(options)
Creates a new CleartextMessage object from text
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
(async) createMessage(options) → {Promise.<Message>}
Creates new message object from text or binary data.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
New message object.
- Type
- Promise.<Message>
(async) decrypt(options) → {Promise.<Object>}
Decrypts a message with the user's private key, a session key or a password. Either a private key, a session key or a password must be specified.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
Object containing decrypted and verified message in the form:
{
data: String|ReadableStream<String>|NodeStream, (if format was 'utf8', the default)
data: Uint8Array|ReadableStream<Uint8Array>|NodeStream, (if format was 'binary')
filename: String,
signatures: [
{
keyID: module:type/keyid~KeyID,
verified: Promise<Boolean>,
valid: Boolean (if `message` was not created from a stream)
}, ...
]
}
- Type
- Promise.<Object>
(async) decryptKey(options) → {Promise.<Key>}
Unlock a private key with the given passphrase. This method does not change the original key.
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
The unlocked key object.
- Type
- Promise.<Key>
(async) decryptSessionKeys(options) → {Promise.<(Object|undefined)>}
Decrypt symmetric session keys with a private key or password. Either a private key or a password must be specified.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
Array of decrypted session key, algorithm pairs in the form: { data:Uint8Array, algorithm:String } or 'undefined' if no key packets found
- Type
- Promise.<(Object|undefined)>
(async) encrypt(options) → {Promise.<(String|ReadableStream.<String>|NodeStream.<String>|Uint8Array|ReadableStream.<Uint8Array>|NodeStream.<Uint8Array>)>}
Encrypts message text/data with public keys, passwords or both at once. At least either public keys or passwords must be specified. If private keys are specified, those will be used to sign the message.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
Encrypted message (string if armor
was true, the default; Uint8Array if armor
was false).
- Type
- Promise.<(String|ReadableStream.<String>|NodeStream.<String>|Uint8Array|ReadableStream.<Uint8Array>|NodeStream.<Uint8Array>)>
(async) encryptKey(options) → {Promise.<Key>}
Lock a private key with the given passphrase. This method does not change the original key.
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
The locked key object.
- Type
- Promise.<Key>
(async) encryptSessionKey(options) → {Promise.<(String|Uint8Array)>}
Encrypt a symmetric session key with public keys, passwords, or both at once. At least either public keys or passwords must be specified.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
Encrypted session keys (string if armor
was true, the default; Uint8Array if armor
was false).
- Type
- Promise.<(String|Uint8Array)>
(async) generateKey(options) → {Promise.<Object>}
Generates a new OpenPGP key pair. Supports RSA and ECC keys. By default, primary and subkeys will be of same type.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
The generated key object in the form: { key:Key, privateKeyArmored:String, publicKeyArmored:String, revocationCertificate:String }
- Type
- Promise.<Object>
(async) generateSessionKey(options) → {Promise.<{data: Uint8Array, algorithm: String}>}
Generate a new session key object, taking the algorithm preferences of the passed public keys into account.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
Object with session key data and algorithm.
- Type
- Promise.<{data: Uint8Array, algorithm: String}>
newPacketFromTag(tag, allowedPackets) → {Object}
Instantiate a new packet given its tag
Parameters:
Name | Type | Description |
---|---|---|
tag |
module:enums.packet | Property value from module:enums.packet |
allowedPackets |
Object | mapping where keys are allowed packet tags, pointing to their Packet class |
- Source:
Returns:
New packet object with type based on tag
- Type
- Object
(async) readCleartextMessage(options) → {Promise.<CleartextMessage>}
Reads an OpenPGP cleartext signed message and returns a CleartextMessage object
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
New cleartext message object.
- Type
- Promise.<CleartextMessage>
(async) readKey(options) → {Promise.<Key>}
Reads an (optionally armored) OpenPGP key and returns a key object
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
Key object.
- Type
- Promise.<Key>
(async) readKeys(options) → {Promise.<Array.<Key>>}
Reads an (optionally armored) OpenPGP key block and returns a list of key objects
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
Key objects.
- Type
- Promise.<Array.<Key>>
(async) readMessage(options) → {Promise.<Message>}
Reads an (optionally armored) OpenPGP message and returns a Message object
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
New message object.
- Type
- Promise.<Message>
(async) readSignature(options) → {Promise.<Signature>}
reads an (optionally armored) OpenPGP signature and returns a signature object
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
New signature object.
- Type
- Promise.<Signature>
(async) reformatKey(options) → {Promise.<Object>}
Reformats signature packets for a key and rewraps key object.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
The generated key object in the form: { key:Key, privateKeyArmored:String, publicKeyArmored:String, revocationCertificate:String }
- Type
- Promise.<Object>
(async) revokeKey(options) → {Promise.<Object>}
Revokes a key. Requires either a private key or a revocation certificate. If a revocation certificate is passed, the reasonForRevocation parameter will be ignored.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
The revoked key object in the form:
{ privateKey:Key, privateKeyArmored:String, publicKey:Key, publicKeyArmored:String }
(if private key is passed) or { publicKey:Key, publicKeyArmored:String }
(otherwise)
- Type
- Promise.<Object>
(async) sign(options) → {Promise.<(String|ReadableStream.<String>|NodeStream.<String>|Uint8Array|ReadableStream.<Uint8Array>|NodeStream.<Uint8Array>)>}
Signs a message.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
Signed message (string if armor
was true, the default; Uint8Array if armor
was false).
- Type
- Promise.<(String|ReadableStream.<String>|NodeStream.<String>|Uint8Array|ReadableStream.<Uint8Array>|NodeStream.<Uint8Array>)>
(async) unarmor(input) → {Promise.<Object>}
Dearmor an OpenPGP armored message; verify the checksum and return the encoded bytes
Parameters:
Name | Type | Description |
---|---|---|
input |
String | OpenPGP armored message |
- Source:
Returns:
An object with attribute "text" containing the message text, an attribute "data" containing a stream of bytes and "type" for the ASCII armor type
- Type
- Promise.<Object>
(async) verify(options) → {Promise.<Object>}
Verifies signatures of cleartext signed message
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
Returns:
Object containing verified message in the form:
{
data: String|ReadableStream<String>|NodeStream, (if `message` was a CleartextMessage)
data: Uint8Array|ReadableStream<Uint8Array>|NodeStream, (if `message` was a Message)
signatures: [
{
keyID: module:type/keyid~KeyID,
verified: Promise<Boolean>,
valid: Boolean (if `message` was not created from a stream)
}, ...
]
}
- Type
- Promise.<Object>