From 66576d3bf5e64b51841e7f43ad16970f183ea447 Mon Sep 17 00:00:00 2001 From: Mads Christiansen Date: Fri, 30 Aug 2024 12:21:17 +0200 Subject: [PATCH] Support multiple vrs in election client (#301) --- lib/av_client.ts | 8 ++++++++ .../connectors/voter_authorization_coordinator.ts | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/av_client.ts b/lib/av_client.ts index 41619b51..aa39c6d2 100644 --- a/lib/av_client.ts +++ b/lib/av_client.ts @@ -205,6 +205,14 @@ export class AVClient implements IAVClient { this.identityConfirmationToken = token } + public async getCoordinatorVoterInfo(): Promise { + 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' diff --git a/lib/av_client/connectors/voter_authorization_coordinator.ts b/lib/av_client/connectors/voter_authorization_coordinator.ts index 03a6a79e..a17120b9 100644 --- a/lib/av_client/connectors/voter_authorization_coordinator.ts +++ b/lib/av_client/connectors/voter_authorization_coordinator.ts @@ -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,