node-forge: Add pkcs7.createEnvelopedData (#43393)

This patch adds typings for `createEnvelopedData` function of `pkcs7`
module and tests that are lifted directly from the README.

See: https://github.com/digitalbazaar/forge#pkcs7
This commit is contained in:
Wiktor Kwapisiewicz 2020-03-27 06:37:31 +01:00 committed by GitHub
parent de4580242d
commit 26be57aaba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -13,6 +13,7 @@
// Sascha Zarhuber <https://github.com/saschazar21>
// Rogier Schouten <https://github.com/rogierschouten>
// Ivan Aseev <https://github.com/aseevia>
// Wiktor Kwapisiewicz <https://github.com/wiktor-k>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
@ -678,6 +679,15 @@ declare module "node-forge" {
}
function createSignedData(): PkcsSignedData;
interface PkcsEnvelopedData {
content?: string | util.ByteBuffer;
addRecipient(certificate: pki.Certificate): void;
encrypt(): void;
toAsn1(): asn1.Asn1;
}
function createEnvelopedData(): PkcsEnvelopedData;
}
namespace pkcs5 {

View File

@ -405,3 +405,12 @@ if (forge.util.fillString('1', 5) !== '11111') throw Error('forge.util.fillStrin
encoding: 'binary'
});
}
{
let p7 = forge.pkcs7.createEnvelopedData();
let cert = forge.pki.certificateFromPem('PEM');
p7.addRecipient(cert);
p7.content = forge.util.createBuffer('content');
p7.encrypt();
let asn1: forge.asn1.Asn1 = p7.toAsn1();
}