From 4978833c4da1a8a90edcdc4be86edb5e64a59bb6 Mon Sep 17 00:00:00 2001 From: Daniel Montesinos Date: Thu, 20 Sep 2018 12:54:26 +0200 Subject: [PATCH 1/2] openpgp.encrypt() now take a message parameter instead of data, dataType and filename. --- types/openpgp/index.d.ts | 19 ++++++++----------- types/openpgp/openpgp-tests.ts | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/types/openpgp/index.d.ts b/types/openpgp/index.d.ts index 6c8e073c04..4c3aad14a0 100644 --- a/types/openpgp/index.d.ts +++ b/types/openpgp/index.d.ts @@ -2,6 +2,7 @@ // 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 From 6fb6e84b17ee9970180a2c3a717fe56e619a499b Mon Sep 17 00:00:00 2001 From: Daniel Montesinos Date: Wed, 26 Sep 2018 09:26:42 +0200 Subject: [PATCH 2/2] Update index.d.ts --- types/openpgp/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/openpgp/index.d.ts b/types/openpgp/index.d.ts index 4c3aad14a0..b671f8484e 100644 --- a/types/openpgp/index.d.ts +++ b/types/openpgp/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for openpgpjs +// Type definitions for openpgp 4.0.0 // Project: http://openpgpjs.org/ // Definitions by: Guillaume Lacasa // Errietta Kostala