diff --git a/lib/av_client.ts b/lib/av_client.ts index 31fe5008..84ea9a73 100644 --- a/lib/av_client.ts +++ b/lib/av_client.ts @@ -230,7 +230,8 @@ export class AVClient implements IAVClient { throw new InvalidConfigError(`Unknown authorization mode of voter authorizer: '${authorizationMode}'`) } - const { authToken } = authorizationResponse.data; + const { authToken, authorizationUuid } = authorizationResponse.data; + this.authorizationSessionId = this.authorizationSessionId ? this.authorizationSessionId : authorizationUuid const decoded = jwtDecode(authToken); // TODO: Verify against dbb pubkey: this.getLatestConfig().services.voterAuthorizer.public_key); @@ -468,7 +469,7 @@ export class AVClient implements IAVClient { const voterAuthorizerContextUuid = this.getLatestConfig().items.voterAuthorizerConfig.content.voterAuthorizer.contextUuid; const coordinator = new VoterAuthorizationCoordinator(coordinatorURL, voterAuthorizerContextUuid); try { - coordinator.sendReceipt(clientReceipt.trackingCode, this.authorizationSessionId); + coordinator.sendReceipt(clientReceipt, this.authorizationSessionId); } catch(e) { console.error(e) } @@ -563,6 +564,10 @@ export class AVClient implements IAVClient { return this.voterSession } + public getSessionUuid(): string { + return this.authorizationSessionId + } + public getVoterBallotConfig(): BallotConfig { const voterSession = this.getVoterSession() const { items: { ballotConfigs } } = this.getLatestConfig() diff --git a/lib/av_client/connectors/voter_authorization_coordinator.ts b/lib/av_client/connectors/voter_authorization_coordinator.ts index 35427860..93c01f46 100644 --- a/lib/av_client/connectors/voter_authorization_coordinator.ts +++ b/lib/av_client/connectors/voter_authorization_coordinator.ts @@ -2,6 +2,7 @@ import axios, { AxiosInstance, AxiosResponse } from 'axios' import { IdentityConfirmationToken } from "./otp_provider"; import { EmailDoesNotMatchVoterRecordError, NetworkError, UnsupportedServerReplyError, VoterRecordNotFoundError } from "../errors"; import { ProofOfElectionCodes } from "../crypto/proof_of_election_codes"; +import { BallotBoxReceipt } from '../types'; export default class VoterAuthorizationCoordinator { private backend: AxiosInstance; @@ -47,11 +48,12 @@ export default class VoterAuthorizationCoordinator { }); } - sendReceipt(trackingCode: string, authorizationSessionId: string): Promise { + sendReceipt(receipt: BallotBoxReceipt, authorizationSessionId: string ): Promise { return this.backend.post('send_receipt', { - trackingCode: trackingCode, + trackingCode: receipt.trackingCode, electionContextUuid: this.electionContextUuid, - authorizationSessionId: authorizationSessionId + authorizationSessionId: authorizationSessionId, + receipt: receipt.receipt }) } diff --git a/package.json b/package.json index 223c8bb6..f918535d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aion-dk/js-client", - "version": "3.1.9", + "version": "3.1.10", "license": "MIT", "description": "Assembly Voting JS client", "main": "dist/lib/av_client.js",