diff --git a/types/openpgp/index.d.ts b/types/openpgp/index.d.ts index 6c8e073c04..b671f8484e 100644 --- a/types/openpgp/index.d.ts +++ b/types/openpgp/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for openpgpjs +// Type definitions for openpgp 4.0.0 // Project: http://openpgpjs.org/ // Definitions by: Guillaume Lacasa // Errietta Kostala +// Daniel Montesinos // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export as namespace openpgp; @@ -11,19 +12,17 @@ export interface UserId { email?: string, } -export interface SessionKey { +export interface SessionKey { data: Uint8Array, algorithm: string } export interface EncryptOptions { - data: string|Uint8Array, - dataType?: 'utf8'|'binary'|'text'|'mime', + message: message.Message publicKeys?: key.Key | key.Key[], privateKeys?: key.Key | key.Key[], - passwords?: string|string[], + passwords?: string | string[], sessionKey?: SessionKey, - filename?: string, compression?: enums.compression, armor?: boolean, detached?: boolean, @@ -80,7 +79,7 @@ export interface Signature { } export interface VerifiedMessage { - data: Uint8Array|string, + data: Uint8Array | string, signatures: Array, filename: string, } @@ -132,13 +131,11 @@ export function destroyWorker(): void; /** * 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. - * @param {String|Uint8Array} data text/data to be encrypted as JavaScript binary string or Uint8Array - * @param {utf8|binary|text|mime} dataType (optional) data packet type + * @param {Message} message message to be encrypted as created by openpgp.message.fromText or openpgp.message.fromBinary * @param {Key|Array} publicKeys (optional) array of keys or single key, used to encrypt the message * @param {Key|Array} privateKeys (optional) private keys for signing. If omitted message will not be signed * @param {String|Array} passwords (optional) array of passwords or a single password to encrypt the message * @param {Object} sessionKey (optional) session key in the form: { data:Uint8Array, algorithm:String } - * @param {String} filename (optional) a filename for the literal data packet * @param {module:enums.compression} compression (optional) which compression algorithm to compress the message with, defaults to what is specified in config * @param {Boolean} armor (optional) if the return values should be ascii armored or the message/signature objects * @param {Boolean} detached (optional) if the signature should be detached (if true, signature will be added to returned object) @@ -608,10 +605,10 @@ export namespace packet { } interface SecretKey extends PublicKey { - read(bytes:string): void; + read(bytes: string): void; write(): string; clearPrivateMPIs(str_passphrase: string): boolean; - encrypt(passphrase:string): void; + encrypt(passphrase: string): void; } /** Allocate a new packet from structured packet clone diff --git a/types/openpgp/openpgp-tests.ts b/types/openpgp/openpgp-tests.ts index 3bd3551d0b..bb34505055 100644 --- a/types/openpgp/openpgp-tests.ts +++ b/types/openpgp/openpgp-tests.ts @@ -22,7 +22,7 @@ var spubkey = '-----BEGIN PGP PUBLIC KEY BLOCK ... END PGP PUBLIC KEY BLOCK----- var publicKey = openpgp.key.readArmored(spubkey); openpgp.encrypt({ - data: 'Hello, World!', + message: openpgp.message.fromText('Hello, World!'), publicKeys: publicKey.keys }).then(function (pgpMessage) { // success