js-nacl: new method random_bytes (#43142)

* feat(js-nacl): new method random_bytes

* docs(js-nacl): up version number in header
This commit is contained in:
Ángel Manuel Martín 2020-03-18 21:23:27 +01:00 committed by GitHub
parent 76bb329370
commit c888b9e91a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -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 <https://github.com/ethanfrey>
// 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;

View File

@ -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
}