diff --git a/openpgp.d.ts b/openpgp.d.ts index 4ec9654e..f7d86edf 100644 --- a/openpgp.d.ts +++ b/openpgp.d.ts @@ -228,18 +228,17 @@ export function decrypt>(options: DecryptOptions & { string }>; -export function verify>(options: VerifyOptions & { message: Message, format: 'binary' }): Promise>; +export function verify>(options: VerifyOptions & { message: Message, format: 'binary' }): Promise ? WebStream : T extends NodeStream ? NodeStream : Uint8Array -}>; -export function verify>(options: VerifyOptions & { message: Message }): Promise>; +export function verify>(options: VerifyOptions & { message: Message }): Promise ? WebStream : T extends NodeStream ? NodeStream : string -}>; +>>; /** Class that represents an OpenPGP message. Can be an encrypted message, signed message, compressed message or literal message */ @@ -721,8 +720,8 @@ interface DecryptMessageResult { filename: string; } -interface VerifyMessageResult { - data: MaybeStream; +interface VerifyMessageResult = MaybeStream> { + data: T; signatures: VerificationResult[]; } diff --git a/test/typescript/definitions.ts b/test/typescript/definitions.ts index f955bdbb..5d61f9c6 100644 --- a/test/typescript/definitions.ts +++ b/test/typescript/definitions.ts @@ -113,6 +113,12 @@ import { // Sign cleartext message (armored) const cleartextMessage = await createCleartextMessage({ text: 'hello' }); + const verificationResult = await verify({ message: cleartextMessage, verificationKeys: publicKey }); + const verifiedCleartextData: string = verificationResult.data; + expect(verifiedCleartextData).to.equal(cleartextMessage.getText()); + // @ts-expect-error Binary output not available for cleartext messages + try { await verify({ message: cleartextMessage, verificationKeys: publicKey, format: 'binary' }) } catch (e) {} + const clearSignedArmor = await sign({ signingKeys: privateKeys, message: cleartextMessage }); expect(clearSignedArmor).to.include('-----BEGIN PGP SIGNED MESSAGE-----'); const clearSignedObject: CleartextMessage = await sign({ signingKeys: privateKeys, message: cleartextMessage, format: 'object' });