Class: AesDrive

AesDrive()

Class provides an abstract virtual drive that can be extended for use with any filesystem ie disk, net, cloud, etc. Each drive implementation needs a corresponding implementation of IFile.

Constructor

new AesDrive()

Source:

Classes

AesDrive

Methods

close()

Close the drive and associated resources.
Source:

(async) createConfigFile(realRoot) → {Promise.<IFile>}

Create the config file for this drive. By default the config file is placed in the real root of the vault. You can override this with your own location, make sure you also override getConfigFile().
Parameters:
Name Type Description
realRoot IFile The real root directory of the vault
Source:
Returns:
The config file that was created
Type
Promise.<IFile>

(async) createSequence(driveId, authId)

Create a nonce sequence for the drive id and the authorization id provided. Should be called once per driveId/authId combination.
Parameters:
Name Type Description
driveId Uint8Array The driveId
authId Uint8Array The authId
Source:
Throws:
Exception If error occurs during creation

(async) getAuthId() → {Promise.<string>}

Get the authorization ID for the current device.
Source:
Throws:
  • SequenceException Thrown if error with the nonce sequence
  • SalmonAuthException Thrown when error during authorization
Returns:
The auth id
Type
Promise.<string>

(async) getAuthIdBytes() → {Promise.<Uint8Array>}

Get the device authorization byte array for the current drive.
Source:
Throws:
Exception If error occurs during retrieval
Returns:
The byte array with the auth id
Type
Promise.<Uint8Array>

(async) getBytesFromRealFile(file, bufferSize)

Get the byte contents of a file from the real filesystem.
Parameters:
Name Type Description
file IFile The file
bufferSize Uint8Array The buffer to be used when reading
Source:

(async) getConfigFile(realRoot) → {Promise.<(IFile|null)>}

Get the config file for this drive. By default the config file is placed in the real root of the vault. You can override this with your own location.
Parameters:
Name Type Description
realRoot IFile The real root directory of the vault
Source:
Returns:
The config file that will be used for this drive.
Type
Promise.<(IFile|null)>

getDefaultFileChunkSize() → {number}

Return the default file chunk size
Source:
Returns:
The default chunk size.
Type
number

(async) getDriveConfig() → {Promise.<(DriveConfig|null)>}

Return the configuration properties of this drive.
Source:
Returns:
The configuration
Type
Promise.<(DriveConfig|null)>

getDriveId() → {Uint8Array|null}

Get the drive id.
Source:
Returns:
The drive id.
Type
Uint8Array | null

(async) getExportDir() → {Promise.<IFile>}

Return the default external export dir that all file can be exported to.
Source:
Returns:
The file on the real filesystem.
Type
Promise.<IFile>

getHashProvider() → {IHashProvider}

Get the has provider for this drive.
Source:
Returns:
The hash provider
Type
IHashProvider

getKey() → {DriveKey|null}

Return the encryption key that is used for encryption / decryption
Source:
Returns:
The drive key
Type
DriveKey | null

(async) getNextNonce() → {Promise.<(Uint8Array|null)>}

Get the next nonce from the sequencer. This advanced the sequencer so unique nonce are used.
Source:
Throws:
Exception
Returns:
The next nonce.
Type
Promise.<(Uint8Array|null)>

(async) getRoot() → {Promise.<(IVirtualFile|null)>}

Return the virtual root directory of the drive.
Source:
Throws:
SalmonAuthException Thrown when error during authorization
Returns:
The virtual file
Type
Promise.<(IVirtualFile|null)>

getSequencer() → {INonceSequencer|undefined}

Get the nonce sequencer used for the current drive.
Source:
Returns:
The nonce sequencer
Type
INonceSequencer | undefined

(async) hasConfig() → {Promise.<boolean>}

Return true if the drive is already created and has a configuration file.
Source:
Returns:
True if configuration file was found
Type
Promise.<boolean>

(async) initFS()

Initialize the drive virtual filesystem.
Source:

(async) initializeSequence(driveId, authId)

Initialize the nonce sequencer with the current drive nonce range. Should be called once per driveId/authId combination.
Parameters:
Name Type Description
driveId Uint8Array Drive ID.
authId Uint8Array Authorization ID.
Source:
Throws:
Exception If error occurs during initialization

(async) revokeAuthorization()

Revoke authorization for this device. This will effectively terminate write operations on the current disk by the current device. Warning: If you need to authorize write operations to the device again you will need to have another device to export an authorization config file and reimport it.
Source:
See:
Throws:
Exception If error occurs during revoke.

setDefaultFileChunkSize(fileChunkSize)

Set the default file chunk size to be used with hash integrity.
Parameters:
Name Type Description
fileChunkSize number
Source:

setKey(masterKey, driveKey, hashKey, iterations)

Sets the key properties.
Parameters:
Name Type Description
masterKey Uint8Array The master key.
driveKey Uint8Array The drive key used for enc/dec of files and filenames.
hashKey Uint8Array The hash key used for data integrity.
iterations number The iterations
Source:

(async) setPassword(pass)

Change the user password.
Parameters:
Name Type Description
pass string The new password.
Source:
Throws:
  • IOException Thrown if there is an IO error.
  • SalmonAuthException Thrown when error during authorization
  • SalmonSecurityException Thrown when error with security
  • IntegrityException Thrown if the data are corrupt or tampered with.
  • SequenceException Thrown if error with the nonce sequence

setSequencer(sequencer)

Set the nonce sequencer used for the current drive.
Parameters:
Name Type Description
sequencer INonceSequencer | undefined The nonce sequencer
Source:

(async, static) createDrive(dir, driveClassType, password, sequencer) → {Promise.<AesDrive>}

Create a new drive in the provided location.
Parameters:
Name Type Description
dir IFile Directory to store the drive configuration and virtual filesystem.
driveClassType any The driver class type (ie Drive).
password string Text password to encrypt the drive configuration.
sequencer INonceSequencer The sequencer to use.
Source:
Throws:
  • IntegrityException Thrown if the data are corrupt or tampered with.
  • SequenceException Thrown if error with the nonce sequence
Returns:
The newly created drive.
Type
Promise.<AesDrive>

(static) getDefaultAuthConfigFilename() → {string}

Get the default auth config filename.
Source:
Returns:
The authorization configuration file name.
Type
string

(async, static) openDrive(dir, driveClassType, password, sequenceropt) → {Promise.<AesDrive>}

Set the drive location to an external directory. This requires you previously use SetDriveClass() to provide a class for the drive
Parameters:
Name Type Attributes Description
dir IFile The directory path that will be used for storing the contents of the drive
driveClassType any The driver class type (ie Drive).
password string Text password to encrypt the drive configuration.
sequencer INonceSequencer <optional>
The sequencer to use.
Source:
Returns:
The drive
Type
Promise.<AesDrive>