Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#53788 node-jose: added iv option to JWE.cr…
Browse files Browse the repository at this point in the history
…eateEncrypt by @ymkjp

* node-jose: added iv option to JWE.createEncrypt

* node-jose: added string along with Buffer for iv option

* Update types/node-jose/index.d.ts

Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>
  • Loading branch information
ymkjp and peterblazejewicz authored Jul 2, 2021
1 parent 5bc20e9 commit 3bb7463
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions types/node-jose/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export namespace JWE {
fields?: object;
contentAlg?: string;
protect?: string | string[];
iv?: string | Buffer;
}

function createEncrypt(keys: JWK.Key | JWK.Key[]): Encryptor;
Expand Down
15 changes: 15 additions & 0 deletions types/node-jose/node-jose-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as jose from 'node-jose';
import * as crypto from "crypto";

const keystore = jose.JWK.createKeyStore();
const output = keystore.toJSON();
Expand Down Expand Up @@ -209,6 +210,20 @@ jose.JWK.createKey('oct', 256, { alg: 'A256GCM' }).then(result => {
// ....
});

jose.JWE.createEncrypt({ iv: Buffer.alloc(96 / 8).toString('base64') }, key)
.update('input')
.final()
.then(result => {
// ....
});

jose.JWE.createEncrypt({iv: crypto.randomBytes(96 / 8) }, key)
.update('input')
.final()
.then(result => {
// ....
});

jose.JWE.createEncrypt([key, key])
.update('input')
.final()
Expand Down

0 comments on commit 3bb7463

Please sign in to comment.