diff --git a/types/js-nacl/index.d.ts b/types/js-nacl/index.d.ts index 94a7cecedf..189d1a7034 100644 --- a/types/js-nacl/index.d.ts +++ b/types/js-nacl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for js-nacl 1.2 +// Type definitions for js-nacl 1.3 // Project: https://github.com/tonyg/js-nacl#readme // Definitions by: Ethan Frey // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -116,6 +116,9 @@ export interface Nacl { crypto_box_seed_keypair: (seed: Uint8Array) => BoxKeyPair; crypto_box_keypair_from_raw_sk: (seed: Uint8Array) => BoxKeyPair; + // random + random_bytes: (length: number) => Uint8Array; + // TODO: crypto_stream // crypto_stream_random_nonce: () => Nonce; // crypto_stream: (len: number, nonce: Nonce, key: StreamKey) => Stream; diff --git a/types/js-nacl/js-nacl-tests.ts b/types/js-nacl/js-nacl-tests.ts index b3336b11f7..1143357675 100644 --- a/types/js-nacl/js-nacl-tests.ts +++ b/types/js-nacl/js-nacl-tests.ts @@ -9,6 +9,7 @@ nacl.instantiate((inst: nacl.Nacl) => { demo_box(inst); demo_secret_box(inst); demo_derived(inst); + demo_random(inst); }); function demo_hex(inst: nacl.Nacl): void { @@ -71,3 +72,7 @@ function demo_derived(inst: nacl.Nacl): void { inst.crypto_box_seed_keypair(seed); // $ExpectType BoxKeyPair inst.crypto_box_keypair_from_raw_sk(seed); // $ExpectType BoxKeyPair } + +function demo_random(inst: nacl.Nacl): void { + inst.random_bytes(32); // $ExpectType Uint8Array +}