Constructor
new FileSequencer(sequenceFile, serializer)
Instantiate a nonce file sequencer.
Parameters:
Name | Type | Description |
---|---|---|
sequenceFile |
IFile | The sequence file (json format). |
serializer |
INonceSequenceSerializer | The serializer to be used. |
Throws:
-
IOException Thrown if there is an IO error.
-
SequenceException Thrown if error with the nonce sequence
Classes
Methods
close()
Close this file sequencer.
(async) createSequence(driveId, authId)
Create a sequence for the drive ID and auth ID provided.
Parameters:
Name | Type | Description |
---|---|---|
driveId |
string | The drive ID. |
authId |
string | The authorization ID of the drive. |
Throws:
SequenceException Thrown if error with the nonce sequence
(async) getContents() → {Promise.<string>}
Get the contents of a sequence file.
Throws:
SequenceException Thrown if error with the nonce sequence
Returns:
The file contents.
- Type
- Promise.<string>
(async) getSequence(driveId) → {Promise.<(NonceSequence|null)>}
Get the sequence by the drive ID.
Parameters:
Name | Type | Description |
---|---|---|
driveId |
string | The drive ID. |
Throws:
SequenceException Thrown if error with the nonce sequence
Returns:
The sequence
- Type
- Promise.<(NonceSequence|null)>
getSequenceFile() → {IFile}
Get the sequence file
Returns:
The sequence file
- Type
- IFile
(async) initialize()
Initialize the file sequencer
(async) initializeSequence(driveId, authId, startNonce, maxNonce)
Initialize the sequence.
Parameters:
Name | Type | Description |
---|---|---|
driveId |
string | The drive ID. |
authId |
string | The auth ID of the device for the drive. |
startNonce |
Uint8Array | The starting nonce. |
maxNonce |
Uint8Array | The maximum nonce. |
Throws:
-
SequenceException Thrown if error with the nonce sequence
-
IOException Thrown if there is an IO error.
(async) nextNonce(driveId) → {Promise.<(Uint8Array|null)>}
Get the next nonce.
Parameters:
Name | Type | Description |
---|---|---|
driveId |
string | The drive ID. |
Throws:
-
SequenceException Thrown if error with the nonce sequence
-
SalmonRangeExceededException Thrown if nonce has exceeded range
Returns:
The next nonce
- Type
- Promise.<(Uint8Array|null)>
(async) revokeSequence(driveId)
Revoke the current sequence for a specific drive.
Parameters:
Name | Type | Description |
---|---|---|
driveId |
string | The drive ID. |
Throws:
SequenceException Thrown if error with the nonce sequence
(async) saveContents(contents)
Save the contents of the file
Parameters:
Name | Type | Description |
---|---|---|
contents |
string | The contents |
(async) saveSequenceFile(sequences)
Save the sequence file.
Parameters:
Name | Type | Description |
---|---|---|
sequences |
Map.<string, NonceSequence> | The sequences. |
Throws:
SequenceException Thrown if error with the nonce sequence
(async) setMaxNonce(driveId, authId, maxNonce)
Set the maximum nonce.
Parameters:
Name | Type | Description |
---|---|---|
driveId |
string | The drive ID. |
authId |
string | The auth ID of the device for the drive. |
maxNonce |
Uint8Array | The maximum nonce. |
Throws:
SequenceException Thrown if error with the nonce sequence