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) → {DecryptParamsBuilder}

Specify the content to decrypt 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
DecryptParamsBuilder

setBufferSource(buffer)

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

setFileSource(source)

Specify a reference to a local file with the TDF ciphertext to decrypt. Only works with node.
Parameters:
Name Type Description
source (node) the path of the local file to decrypt, or the Blob (browser/node)

setRcaSource(rcaParams)

Parameters:
Name Type Description
rcaParams

(async) setRemoteStore(fileName, configopt, credentialURLopt) → {DecryptParamsBuilder}

Specify the remote content to decrypt in stream form. withRemoteStore() has not been implemented because setRemoteStore() is async so withRemoteStore() can't be chained with a build() call.
Parameters:
Name Type Attributes Description
fileName string the name of the remote file to write TDF ciphertext to.
config S3ClientConfig <optional>
the object containing remote storage configuration.
A detailed spec for the interface can be found here
credentialURL string <optional>
the url to request remote storage credentials from.
Credentials can be generated using GetFederationToken
Returns:
- this object.
Type
DecryptParamsBuilder

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.

setUrlSource(url)

Specify the TDF ciphertext to decrypt, from an http(s) URL. TODO: add support for TDF.html encoding
Parameters:
Name Type Description
url string a url pointing to a tdf3 file

withArrayBufferSource(arraybuffer) → {DecryptParamsBuilder}

Specify 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
DecryptParamsBuilder

withBufferSource(buffer) → {DecryptParamsBuilder}

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

withFileSource(source)

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
source (node) the path of the local file to decrypt, or the Blob (browser/node)

withRcaSource(rcaParams) → {DecryptParamsBuilder}

Use it with .withStreamSource
Parameters:
Name Type Description
rcaParams
Returns:
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

withUrlSource(url) → {DecryptParamsBuilder}

Specify the TDF ciphertext to decrypt, as a URL.
Parameters:
Name Type Description
url string a tdf3 remote URL.
Returns:
- this object.
Type
DecryptParamsBuilder