Options
All
  • Public
  • Public/Protected
  • All
Menu

Used to store and retrieve a sensitive information in memory. This is not meant for at rest encryption.

example

const sString: SecureBuffer = new SecureBuffer(); sString.consume(secretTextBuffer); const value: string = sString.value((buffer: Buffer): string => { const password: string = buffer.toString('utf8'); // doSomething with the password // returns something of type return testReturnValue; });

Type parameters

  • T

Hierarchy

  • SecureBuffer

Index

Methods

Methods

clear

  • clear(): void
  • Overwrites the value of the encrypted secret with random data.

    Returns void

consume

  • consume(buffer: Buffer): void
  • Consumes a buffer of data that's intended to be secret.

    Parameters

    • buffer: Buffer

      Data to encrypt. The input buffer is overwritten with random data after it's encrypted and assigned internally.

    Returns void

value

  • value(cb: function): Optional<T>
  • Invokes a callback with a decrypted version of the buffer.

    Parameters

    • cb: function

      The callback containing the decrypted buffer parameter that returns a desired typed object. It's important to understand that once the callback goes out of scope the buffer parameters is overwritten with random data. Do not make a copy of this buffer and persist it!

        • (buffer: Buffer): T
        • Parameters

          • buffer: Buffer

          Returns T

    Returns Optional<T>

    T - The value of the callback of type T