DecryptParamsBuilder

DecryptParamsBuilder

A builder capable of constructing the necessary parameters object for a decrypt operation. Must be built using the build() function.

Decrypt does not currently allow for setting a stream window size. Support for this configuration will be added in the near future.

Example usage:
  // Configure the parameters to decrypt a local file.
  const decryptParams = new Virtru.DecryptParamsBuilder()
    .withFileSource("encrypted.html")
    .build();
  
  // Run the decrypt and write the result to stdout (node-style).
  (await client.decrypt(decryptParams)).pipe(process.stdout);
  

Constructor

new DecryptParamsBuilder()

Methods

build()

Generate a parameters object in the form expected by decrypt.

Creates a deep copy to prevent tricky call-by-reference and async execution bugs.

setArrayBufferSource(arraybuffer) → {EncryptParamsBuilder}

Specify the content to encrypt using an ArrayBuffer reference, which must have already loaded the file content. Using the below linked example, e.target.result is the ArrayBuffer

Example: https://developer.mozilla.org/en-US/docs/Web/API/FileReader/onload
Parameters:
Name Type Description
arraybuffer ArrayBuffer the array buffer containing the file to decrypt.
Returns:
- this object
Type
EncryptParamsBuilder

setBufferSource(buf)

Set the TDF ciphertext to decrypt, in buffer form.
Parameters:
Name Type Description
buf Buffer a buffer to decrypt.

setFileSource(filepath)

Specify a reference to a local file with the TDF ciphertext to decrypt. Only works with node.
Parameters:
Name Type Description
filepath string the path of the local file to decrypt.

setStreamSource(stream)

Specify the TDF ciphertext to decrypt, in stream form.
Parameters:
Name Type Description
stream Readable a Readable stream to decrypt.

setStringSource(string)

Specify the TDF ciphertext to decrypt, in string form.
Parameters:
Name Type Description
string string a string to decrypt.

withArrayBufferSource(arraybuffer) → {EncryptParamsBuilder}

Specifcy the content to decrypt using an ArrayBuffer reference. Returns this object for method chaining.
Parameters:
Name Type Description
arraybuffer ArrayBuffer the ArrayBuffer used to load file content from a browser
Returns:
- this object.
Type
EncryptParamsBuilder

withBufferSource(buf) → {DecryptParamsBuilder}

Set the TDF ciphertext to decrypt, in buffer form. Returns this object for method chaining.
Parameters:
Name Type Description
buf Buffer a buffer to decrypt.
Returns:
- this object.
Type
DecryptParamsBuilder

withFileSource(filepath) → {DecryptParamsBuilder}

Specify a reference to a local file with the TDF ciphertext to decrypt. Only works with node. Returns this object for method chaining.
Parameters:
Name Type Description
filepath string the path of the local file to decrypt.
Returns:
- this object.
Type
DecryptParamsBuilder

withStreamSource(stream) → {DecryptParamsBuilder}

Specify the TDF ciphertext to decrypt, in stream form. Returns this object for method chaining.
Parameters:
Name Type Description
stream Readable a Readable stream to decrypt.
Returns:
- this object.
Type
DecryptParamsBuilder

withStringSource(string) → {DecryptParamsBuilder}

Specify the TDF ciphertext to decrypt, in string form. Returns this object for method chaining.
Parameters:
Name Type Description
string string a string to decrypt.
Returns:
- this object.
Type
DecryptParamsBuilder