URL to the Assembly Voting backend server, specific for election.
OptionaldbbPublicKey: stringInitializes the client with an election config. If no config is provided, it fetches one from the backend.
OptionallatestConfig: LatestConfigAllows injection of an election configuration for testing purposes
OptionalkeyPair: KeyPairAllows injection of a keypair to support automatic testing
Returns undefined if succeeded or throws an error
NetworkError if any request failed to get a response
Should be called when a voter chooses digital vote submission (instead of mail-in).
Will attempt to get backend services to send an access code (one time password, OTP) to voter's email address.
Should be followed by validateAccessCode to submit access code for validation.
Voter ID that preserves voter anonymity.
where the voter expects to receive otp code.
OptionalballotReference: stringThe ballot which which voter voter intends to vote on
Returns undefined or throws an error.
NetworkError if any request failed to get a response
Should be called after requestAccessCode.
Takes an access code (OTP) that voter received, uses it to authorize to submit votes.
Internally, generates a private/public key pair, then attempts to authorize the public key with each OTP provider.
Should be followed by AVClient.constructBallotCryptograms | constructBallotCryptograms.
An access code string.
Returns undefined if authorization succeeded or throws an error
InvalidStateError if called before required data is available
AccessCodeExpired if an OTP code has expired
AccessCodeInvalid if an OTP code is invalid
NetworkError if any request failed to get a response
Registers a voter based on the authorization mode of the Voter Authorizer Authorization is done by 'proof-of-identity' or 'proof-of-election-codes'
Registers a voter based on the authorization mode of the Voter Authorizer
undefined or throws an error
Should be called after validateAccessCode.
Encrypts a ballot-selection (CVR) and generates vote cryptograms.
Example:
const client = new AVClient(url);
const cvr = { '1': 'option1', '2': 'optiona' };
const trackingCode = await client.constructBallotCryptograms(cvr);
Example of handling errors:
try {
await client.constructBallotCryptograms({});
} catch(error) {
if(error instanceof AvClientError) {
switch(error.name) {
case 'InvalidStateError':
console.log("State is not valid for this call");
break;
case 'NetworkError':
console.log("It's a network error");
break;
default:
console.log('Something else was wrong');
}
}
}
Where '1' and '2' are contest ids, and 'option1' and 'optiona' are
values internal to the AV election config.
Should be followed by either spoilBallot or castBallot.
BallotSelection containing the selections for each contest.
Returns the ballot tracking code. Example:
'5e4d8fe41fa3819cc064e2ace0eda8a847fe322594a6fd5a9a51c699e63804b7'
InvalidStateError if called before required data is available
CorruptCvrError if the cast vote record is invalid
NetworkError if any request failed to get a response
Should be the last call in the entire voting process.
Requests that the previously constructed ballot is cast.
The locale which the email with the vote receipt should be sent in
Returns the vote receipt. Example of a receipt:
{
previousBoardHash: 'd8d9742271592d1b212bbd4cbvobbe357aef8e00cdbdf312df95e9cf9a1a921465',
boardHash: '5a9175c2b3617298d78be7d0244a68f34bc8b2a37061bb4d3fdf97edc1424098',
registeredAt: '2020-03-01T10:00:00.000+01:00',
serverSignature: 'dbcce518142b8740a5c911f727f3c02829211a8ddfccabeb89297877e4198bc1,46826ddfccaac9ca105e39c8a2d015098479624c411b4783ca1a3600daf4e8fa',
voteSubmissionId: 6
}
NetworkError if any request failed to get a response
Should be called when voter chooses to test the encryption of their ballot. Gets commitment opening of the digital ballot box and validates it.
Returns undefined if the validation succeeds or throws an error
InvalidStateError if called before required data is available
NetworkError if any request failed to get a response
Should be called when the voter has 'paired' the verifier and the voting app. Computes and encrypts the clientEncryptionCommitment and posts it to the DBB
Returns void if the computation was succesful
InvalidStateError if called before required data is available
NetworkError if any request failed to get a response
Should be called after spoilBallot. Gets the verifier public key from the DBB
Returns the pairing code based on the address of the verifier item in the DBB
InvalidStateError if called before required data is available
TimeoutError if the verifier doesn't register itself to the DBB in time
NetworkError if any request failed to get a response
Finds the ballot status corresponding to the given trackingcode. Also returns the activities associated with the ballot
base58-encoded trackingcode
Disables the voter in the VA, so that they can no longer vote or sign in.
Assembly Voting Client API
The API is responsible for handling all the cryptographic operations and all network communication with:
Expected sequence of methods being executed
Example walkthrough test