Skip to content

Commit

Permalink
Support multiple vrs in election client (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
av-mads authored Aug 30, 2024
1 parent dc0dccb commit 66576d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/av_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ export class AVClient implements IAVClient {
this.identityConfirmationToken = token
}

public async getCoordinatorVoterInfo(): Promise<AxiosResponse> {
const coordinatorURL = this.getLatestConfig().items.voterAuthorizerConfig.content.voterAuthorizer.url;
const voterAuthorizerContextUuid = this.getLatestConfig().items.voterAuthorizerConfig.content.voterAuthorizer.contextUuid;
const coordinator = new VoterAuthorizationCoordinator(coordinatorURL, voterAuthorizerContextUuid);
const identification = this.getLatestConfig().items.voterAuthorizerConfig.content.voterAuthorizer.authorizationMode === 'proof-of-identity' ? this.identityConfirmationToken : this.proofOfElectionCodes.mainKeyPair.publicKey
return await coordinator.getVoterInfo(identification)
}

/**
* Registers a voter based on the authorization mode of the Voter Authorizer
* Authorization is done by 'proof-of-identity' or 'proof-of-election-codes'
Expand Down
8 changes: 8 additions & 0 deletions lib/av_client/connectors/voter_authorization_coordinator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ export default class VoterAuthorizationCoordinator {
})
}

getVoterInfo(identification: string) {
return this.backend.get("voter_info", {
params: {
identification: identification,
},
});
}

private createBackendClient(baseURL: string, timeout: number) {
this.backend = axios.create({
baseURL: baseURL,
Expand Down

0 comments on commit 66576d3

Please sign in to comment.